Skip to content

Commit b3f652b

Browse files
authored
fix: eagerly read torrent attributes before spawning greenlet (#151)
Avoid `RuntimeError: Working outside of application context` when trying to access properties on `torrent` during batch operation. Closes #150
1 parent c9a1834 commit b3f652b

1 file changed

Lines changed: 10 additions & 1 deletion

File tree

betanin/notifications.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import random
33
import string
44
from string import Template
5+
from types import SimpleNamespace
56

67
# 3rd party
78
import gevent
@@ -124,4 +125,12 @@ def send(torrent):
124125

125126

126127
def send_async(torrent):
127-
gevent.spawn(send, torrent)
128+
gevent.spawn(
129+
send,
130+
SimpleNamespace(
131+
id=torrent.id,
132+
name=torrent.name,
133+
updated=torrent.updated,
134+
status=torrent.status,
135+
),
136+
)

0 commit comments

Comments
 (0)