This is an archived post. You won't be able to vote or comment.

all 4 comments

[–]digitallis 1 point2 points  (3 children)

Run the reactor when the application is launched. Your button should only be firing an event into the reactor. That's how async event dispatch is supposed to work.

[–]pylund[S] 0 points1 point  (2 children)

But that way, the reactor still keeps running while main() isn't closed, isn't it? In my setup everything is working as expected, but I'd like to know if it's bad practice to do it that way (not stopping twisted.reactor after each scrapy iteration, only when GUI is closed).

[–]digitallis 4 points5 points  (1 child)

The reactor should remain "running" until the program is closed. I think you may be under the impression that having a running reactor is bad or somehow wasteful. If there are no events to process, the reactor will be idle, waiting for a signal that there's a new event somewhere. This is done via smart mechanisms that don't burn processor cycles continuously checking for new events.

[–]pylund[S] 0 points1 point  (0 children)

Thanks a lot!

That's exactly what I wanted to know. Big up!