Skip to content

Commit 2ffbdcb

Browse files
committed
Get future result in a callback
1 parent 030c8a1 commit 2ffbdcb

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

scrapy_playwright/_utils.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -122,10 +122,11 @@ def get_event_loop(cls) -> asyncio.AbstractEventLoop:
122122

123123
@classmethod
124124
async def get_result(cls, coro) -> concurrent.futures.Future:
125-
return asyncio.run_coroutine_threadsafe(coro=coro, loop=cls.get_event_loop()).result()
125+
return asyncio.run_coroutine_threadsafe(coro=coro, loop=cls.get_event_loop())
126126

127127
def _deferred_from_coro(coro) -> Deferred:
128-
return scrapy.utils.defer.deferred_from_coro(_WindowsAdapter.get_result(coro))
128+
dfd = scrapy.utils.defer.deferred_from_coro(_WindowsAdapter.get_result(coro))
129+
return dfd.addCallback(lambda future: future.result())
129130

130131
else:
131132
_deferred_from_coro = scrapy.utils.defer.deferred_from_coro

0 commit comments

Comments
 (0)