Skip to content

Commit

Permalink
Bugfix/fix memery leaky duraing start (#871)
Browse files Browse the repository at this point in the history
* signal stop handler move to starting

* remove invalid code

* version

---------

Co-authored-by: noO0ob <[email protected]>
  • Loading branch information
noO0oOo0ob and noO0ob authored Jul 10, 2024
1 parent 76791cc commit 53d8051
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 16 deletions.
1 change: 0 additions & 1 deletion lyrebird/application.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,6 @@ def destory(self):
for lock in self.async_objs['locks']:
del lock
self.manager.shutdown()
self.manager.join()
self.manager = None
self.async_objs = None

Expand Down
29 changes: 15 additions & 14 deletions lyrebird/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,21 @@ def main():
print(version.LYREBIRD)
return

# stop event handler
def signal_handler(signum, frame):
application.stop_server()
application.terminate_server()
if application.sync_manager:
application.sync_manager.destory()
if application.config and application.config.get('enable_multiprocess', False):
RedisManager.destory()
threading.Event().set()
print('!!!Ctrl-C pressed. Lyrebird stop!!!')
os._exit(0)

signal.signal(signal.SIGINT, signal_handler)
signal.signal(signal.SIGTERM, signal_handler)

Path('~/.lyrebird').expanduser().mkdir(parents=True, exist_ok=True)

custom_conf = {es[0]: es[1] for es in args.extra_string} if args.extra_string else {}
Expand Down Expand Up @@ -265,20 +280,6 @@ def run(args: argparse.Namespace):
# main process is ready, publish system event
application.status_ready()

# stop event handler
def signal_handler(signum, frame):
application.stop_server()
application.terminate_server()
application.sync_manager.destory()
if application.config.get('enable_multiprocess', False):
RedisManager.destory()
threading.Event().set()
print('!!!Ctrl-C pressed. Lyrebird stop!!!')
os._exit(0)

signal.signal(signal.SIGINT, signal_handler)
signal.signal(signal.SIGTERM, signal_handler)

threading.Event().wait()


Expand Down
2 changes: 1 addition & 1 deletion lyrebird/version.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
IVERSION = (3, 0, 4)
IVERSION = (3, 0, 5)
VERSION = ".".join(str(i) for i in IVERSION)
LYREBIRD = "Lyrebird " + VERSION

0 comments on commit 53d8051

Please sign in to comment.