Closed ofacklam closed 1 year ago
I think that assigning to fut
and having callback
close around it might be enough. I really don't want to get in the business of storing futures in a set and tests are consistently behaving so I'm going to hold off on anything more obvious, but if there ends up being a concrete bug I'm happy to take a closer look.
When _emit_run
finishes, fut
is out of scope, so the future may be garbage-collected. This causes a bug in playwright that loses events, as the corresponding futures vanish before they're fully executed and the corresponding error message appears when the program finishes. A solution is to store the futures in a file-level variable, then use the callback
to remove them once finished.
Is there any further conclusion here?
I'm currently pushing a fix in v9.1.1 - give it a shot, and if you still have issues let me know.
For the record, we're still observing this issue with pyee==11.0.0 (see https://github.com/scrapy-plugins/scrapy-playwright/issues/188 & https://github.com/scrapy-plugins/scrapy-playwright/issues/233). I'm mostly leaving this message to keep track of this, at the time I'm not able to provide a reproducible example using only pyee and I'm well aware that the issues I mentioned add two layers of dependencies :disappointed:.
The documentation for
asyncio.ensure_future
indicates:Currently, this doesn't seem to be the case in
AsyncIOEventEmitter
, which to my understanding only adds a "done" callback, but doesn't keep the future's reference any longer.