Browse Source

bugfix, last commit introduced a syntax error. properly awaiting handle_tasks.cancel_remaining now

digital 7 năm trước cách đây
mục cha
commit
3592d7f248
1 tập tin đã thay đổi với 6 bổ sung3 xóa
  1. 6 3
      network/__init__.py

+ 6 - 3
network/__init__.py

@@ -226,15 +226,18 @@ class Server(object):
         it unregisters itself from atexit, so it doesn't get executed twice
         when it was manually called before to program exits.
         """
-        def error_handler(func,*args,log_text="error",**kwargs):
+        def error_handler(func,*args,log_text="error",async_=True,**kwargs):
             try:
-                func(*args,**kwargs)
+                if async:
+                    await func(*args,**kwargs)
+                else:
+                    func(*args,**kwargs)
             except Exception as exc:
                 lserver.debug("error occured during "+log_text,exc_info=exc)
         atexit.unregister(self.shutdown)
         lserver.info("shutting down server")
         error_handler(
-            await self.handle_tasks.cancel_remaining,log_text="handler cancel")
+            self.handle_tasks.cancel_remaining,log_text="handler cancel",async_=True)
         # check if there is actually a socket. if the shutdown method is
         # executed before the start method, there is no socket.
         if self.socket: