I am writing a code of the consumer producer problem in python , so far I am almost ready but my code still not running.. Would you help me in any way to finish it, I am new in python and am not sure what I do wrong, any help is appreciated.
Kind regards
Vineet
#!/usr/bin/python
# -*- coding: utf-8 -*-
__author__=
import time
from threading import Thread, Lock
wallet = []
lock = Lock()
global obj
def producer(obj):
lock.acquire()
for i in range(10):
obj = obj + i
wallet.append(obj)
time.sleep(1)
lock.release()
def consumer():
lock.acquire()
for i in range(10):
obj = obj - i
obj = wallet.pop()
lock.release()
return obj