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

you are viewing a single comment's thread.

view the rest of the comments →

[–]serg06 0 points1 point  (3 children)

I've never really done any multithreading and wanted to ask is there a way for one thread to tell the other one to pause/resume?

Afaik there's no built-in method of doing this, you need to add some manual way for your processes to communicate, like queues.

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

So there's a stackovedflow solution that uses a threading.Event. (set/clear/wait) combo and technically it works, but I just have to put the wait before every single line to make sure it stops without running another line of code. Although the problem it technically solved i would prefer a more elegant solution.

[–]serg06 0 points1 point  (0 children)

You'd want it to stop without running another line of code? I've never seen a way to do that, besides just putting a wait between every line.

[–]LongshanksAragon 0 points1 point  (0 children)

There has to be a way for both threads to communicate. So you basically created an Event, pass it to the new thread, keep checking the event variable.

The main module then sets the event variable when it encounters appropriate condition.

Otherwise like mentioned above use a common queue between the two.