-
Notifications
You must be signed in to change notification settings - Fork 189
Closed
Labels
enhancementNew feature or requestNew feature or request
Description
This code should go to end but in VS Code does not. In others IDE this run to the end.
Is this BUG or?
Code is:
import logging
import random
import threading
import time
logging.basicConfig(
level=logging.DEBUG,
format='(%(threadName)-10s) %(message)s',
)
class Counter(object):
def __init__(self, start=0):
self.lock = threading.Lock()
self.value = start
def increment(self):
logging.debug('Waiting for lock')
self.lock.acquire()
try:
logging.debug('Acquired lock')
self.value = self.value + 1
finally:
logging.debug("Releasing")
self.lock.release()
def worker(c):
print('Entering worker...')
for i in range(2):
print('worker loop:', i)
pause = random.random()
logging.debug('Sleeping %0.02f', pause)
time.sleep(pause)
c.increment()
logging.debug('Done')
counter = Counter()
for i in range(2):
t = threading.Thread(target=worker, args=(counter,))
t.start()
logging.debug('Waiting for worker threads')
main_thread = threading.currentThread()
try:
for t in threading.enumerate():
if t is not main_thread:
t.join()
except Exception as e:
print('exception: ', e)
finally:
print('This is test')
logging.debug('Counter: %d', counter.value)
logging.debug('End of script')
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request