Created
December 21, 2020 20:10
-
-
Save rendarz/fbadac091b0af526aaaacb6a603ee043 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
with self.lock: | |
current_list = namespace[name] | |
new_list = [] | |
for element in current_list: | |
element.do_the_stuff() | |
if element.isAlive(): | |
new_list.append(element) | |
with self.lock: | |
namespace[name] = new_list | |
# _____________________________________ | |
with self.lock: | |
entry = get_first_entry_from_prio_queue() | |
entry.do_the_thing() | |
if entry.isAlive(): | |
with self.lock(): | |
insert_again_into_prio_queue(entry) |
amcgregor
commented
Dec 21, 2020
I have solved like this:
new_list = []
with self.lock:
current_list = ns[name]
for item in current_list:
do_checkings()
if item.isAlive():
new_list.append(item)
ns[name] = new_list
for item in new_list:
item.do_lenghty_job()
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment