mirror of
https://github.com/chatmail/core.git
synced 2026-05-16 21:36:30 +03:00
python: fix basic start and stop
This commit is contained in:
@@ -19,7 +19,6 @@ from .tracker import ImexTracker
|
|||||||
from . import hookspec, iothreads
|
from . import hookspec, iothreads
|
||||||
from .eventlogger import FFIEvent
|
from .eventlogger import FFIEvent
|
||||||
|
|
||||||
|
|
||||||
class MissingCredentials(ValueError):
|
class MissingCredentials(ValueError):
|
||||||
""" Account is missing `addr` and `mail_pw` config values. """
|
""" Account is missing `addr` and `mail_pw` config values. """
|
||||||
|
|
||||||
@@ -63,7 +62,6 @@ class Account(object):
|
|||||||
self._configkeys = self.get_config("sys.config_keys").split()
|
self._configkeys = self.get_config("sys.config_keys").split()
|
||||||
atexit.register(self.shutdown)
|
atexit.register(self.shutdown)
|
||||||
hook.dc_account_init(account=self)
|
hook.dc_account_init(account=self)
|
||||||
self._threads.start()
|
|
||||||
|
|
||||||
def disable_logging(self):
|
def disable_logging(self):
|
||||||
""" disable logging. """
|
""" disable logging. """
|
||||||
@@ -576,6 +574,7 @@ class Account(object):
|
|||||||
raise MissingCredentials("addr or mail_pwd not set in config")
|
raise MissingCredentials("addr or mail_pwd not set in config")
|
||||||
lib.dc_configure(self._dc_context)
|
lib.dc_configure(self._dc_context)
|
||||||
lib.dc_context_run(self._dc_context)
|
lib.dc_context_run(self._dc_context)
|
||||||
|
self._threads.start()
|
||||||
|
|
||||||
def wait_shutdown(self):
|
def wait_shutdown(self):
|
||||||
""" wait until shutdown of this account has completed. """
|
""" wait until shutdown of this account has completed. """
|
||||||
@@ -591,6 +590,7 @@ class Account(object):
|
|||||||
if self._threads.is_started():
|
if self._threads.is_started():
|
||||||
self.stop_ongoing()
|
self.stop_ongoing()
|
||||||
self._threads.stop(wait=False)
|
self._threads.stop(wait=False)
|
||||||
|
|
||||||
lib.dc_context_shutdown(dc_context)
|
lib.dc_context_shutdown(dc_context)
|
||||||
lib.dc_close(dc_context)
|
lib.dc_close(dc_context)
|
||||||
self._threads.stop(wait=wait) # to wait for threads
|
self._threads.stop(wait=wait) # to wait for threads
|
||||||
@@ -608,7 +608,7 @@ class Account(object):
|
|||||||
if self._in_use_iter_events:
|
if self._in_use_iter_events:
|
||||||
raise RuntimeError("can only call iter_events() from one thread")
|
raise RuntimeError("can only call iter_events() from one thread")
|
||||||
self._in_use_iter_events = True
|
self._in_use_iter_events = True
|
||||||
while 1:
|
while lib.dc_is_open(self._dc_context):
|
||||||
event = lib.dc_get_next_event(self._dc_context)
|
event = lib.dc_get_next_event(self._dc_context)
|
||||||
if event == ffi.NULL:
|
if event == ffi.NULL:
|
||||||
break
|
break
|
||||||
|
|||||||
Reference in New Issue
Block a user