Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use threading.Lock instead of mp.Lock #1972

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions python/cog/server/worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ def _publish(self, ev: _PublicEventType) -> None:
class LockedConn:
def __init__(self, conn: Connection) -> None:
self.conn = conn
self._lock = _spawn.Lock()
self._lock = threading.Lock()

def send(self, obj: Any) -> None:
with self._lock:
Expand All @@ -266,7 +266,7 @@ def __init__(
) -> None:
self._predictor_ref = predictor_ref
self._predictor: Optional[BasePredictor] = None
self._events = LockedConn(events)
self._unwrapped_events = events
self._tee_output = tee_output
self._cancelable = False

Expand All @@ -280,6 +280,7 @@ def run(self) -> None:

# We use SIGUSR1 to signal an interrupt for cancelation.
signal.signal(signal.SIGUSR1, self._signal_handler)
self._events = LockedConn(self._unwrapped_events)

redirector = StreamRedirector(
tee=self._tee_output,
Expand Down
Loading