Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions intro-to-threading/fixrace.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,8 @@ def locked_update(self, name):
# logging.getLogger().setLevel(logging.DEBUG)

database = FakeDatabase()
logging.info(
"Testing locked update. Starting value is %d.", database.value
)
logging.info("Testing update. Starting value is %d.", database.value)
with concurrent.futures.ThreadPoolExecutor(max_workers=2) as executor:
for index in range(2):
executor.submit(database.locked_update, index)
logging.info("Testing locked update. Ending value is %d.", database.value)
logging.info("Testing update. Ending value is %d.", database.value)
2 changes: 1 addition & 1 deletion intro-to-threading/prodcom_better_queue.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def producer(queue, event):

def consumer(queue, event):
"""Pretend we're saving a number in the database."""
while not event.is_set() or not pipeline.empty():
while not event.is_set() or not queue.empty():
message = queue.get()
logging.info(
"Consumer storing message: %s (size=%d)", message, queue.qsize()
Expand Down
4 changes: 2 additions & 2 deletions intro-to-threading/single_thread.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def thread_function(name):
logging.info("Main : before creating thread")
x = threading.Thread(target=thread_function, args=(1,))
logging.info("Main : before running thread")
# x.start()
x.start()
logging.info("Main : wait for the thread to finish")
x.join()
# x.join()
logging.info("Main : all done")
Loading