Skip to content

Commit

Permalink
Supported automatically calling close() at exit. (#290) (#292)
Browse files Browse the repository at this point in the history
  • Loading branch information
ATATC authored Jul 15, 2024
1 parent 8467672 commit 1e5570f
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions leads/comm/prototype.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from abc import abstractmethod as _abstractmethod, ABCMeta as _ABCMeta
from atexit import register as _register
from socket import socket as _socket, AF_INET as _AF_INET, SOCK_STREAM as _SOCK_STREAM, \
gethostbyname_ex as _gethostbyname_ex, gethostname as _gethostname, gaierror as _gaierror, herror as _herror
from threading import Lock as _Lock, Thread as _Thread
Expand All @@ -24,6 +25,7 @@ def __init__(self, port: int) -> None:
self._port: int = port
self._socket: _socket = _socket(_AF_INET, _SOCK_STREAM, proto=0)
self._main_thread: _Thread | None = None
_register(self.close)

def port(self) -> int:
"""
Expand Down

0 comments on commit 1e5570f

Please sign in to comment.