Visitar URL original
Refactor Dispatcher's worker · stack-queue/pyrogram@392fea6 · GitHub
Skip to content

Commit 392fea6

Browse files
committed
Refactor Dispatcher's worker
Closes #211
1 parent 429cfd0 commit 392fea6

1 file changed

Lines changed: 23 additions & 24 deletions

File tree

‎pyrogram/client/dispatcher/dispatcher.py‎

Lines changed: 23 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -130,34 +130,33 @@ def update_worker(self):
130130

131131
parsed_update, handler_type = (
132132
parser(update, users, chats)
133-
if parser
134-
else (None, type)
133+
if parser is not None
134+
else (None, type(None))
135135
)
136136

137137
for group in self.groups.values():
138-
try:
139-
for handler in group:
140-
args = None
141-
142-
if isinstance(handler, RawUpdateHandler):
143-
args = (update, users, chats)
144-
elif isinstance(handler, handler_type):
145-
if handler.check(parsed_update):
146-
args = (parsed_update,)
147-
148-
if args is None:
149-
continue
150-
151-
try:
152-
handler.callback(self.client, *args)
153-
except StopIteration:
154-
raise
155-
except Exception as e:
156-
log.error(e, exc_info=True)
157-
158-
break
159-
except StopIteration:
138+
for handler in group:
139+
args = None
140+
141+
if isinstance(handler, handler_type):
142+
if handler.check(parsed_update):
143+
args = (parsed_update,)
144+
elif isinstance(handler, RawUpdateHandler):
145+
args = (update, users, chats)
146+
147+
if args is None:
148+
continue
149+
150+
try:
151+
handler.callback(self.client, *args)
152+
except pyrogram.StopPropagation:
153+
raise
154+
except Exception as e:
155+
log.error(e, exc_info=True)
156+
160157
break
158+
except pyrogram.StopPropagation:
159+
pass
161160
except Exception as e:
162161
log.error(e, exc_info=True)
163162

0 commit comments

Comments
 (0)