mirror of
https://github.com/chatmail/core.git
synced 2026-05-22 08:16:32 +03:00
python: run and shutdown
This commit is contained in:
@@ -654,9 +654,7 @@ pub unsafe extern "C" fn dc_context_shutdown(context: *mut dc_context_t) {
|
|||||||
let ffi_context = &*context;
|
let ffi_context = &*context;
|
||||||
|
|
||||||
with_inner_async!(ffi_context, ctx, async move {
|
with_inner_async!(ffi_context, ctx, async move {
|
||||||
eprintln!("SHUTDOWN");
|
|
||||||
ctx.stop().await;
|
ctx.stop().await;
|
||||||
eprintln!("SHUTDOWN:DONE")
|
|
||||||
})
|
})
|
||||||
.unwrap_or(())
|
.unwrap_or(())
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -575,6 +575,7 @@ class Account(object):
|
|||||||
if not self.get_config("addr") or not self.get_config("mail_pw"):
|
if not self.get_config("addr") or not self.get_config("mail_pw"):
|
||||||
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)
|
||||||
|
|
||||||
def wait_shutdown(self):
|
def wait_shutdown(self):
|
||||||
""" wait until shutdown of this account has completed. """
|
""" wait until shutdown of this account has completed. """
|
||||||
@@ -590,6 +591,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_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
|
||||||
self._dc_context = None
|
self._dc_context = None
|
||||||
|
|||||||
@@ -54,7 +54,6 @@ class IOThreads:
|
|||||||
ev = next(it)
|
ev = next(it)
|
||||||
except StopIteration:
|
except StopIteration:
|
||||||
break
|
break
|
||||||
print("{}", ev)
|
|
||||||
self.account.ac_log_line("calling hook name={} kwargs={}".format(ev.name, ev.kwargs))
|
self.account.ac_log_line("calling hook name={} kwargs={}".format(ev.name, ev.kwargs))
|
||||||
ev.call_hook()
|
ev.call_hook()
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user