3/18/2014

Python Study, put_nowait(), get_nowait(), example source code

#put_nowait, get_nowait method


import queue
q = queue.Queue(2) #buffer size is 2
q.put("apple")
q.put("banana")
#q.put("orange")  # wait infinity until there is available space


#q.put_nowait("orange") #error occurs
# Line 187, in put_nowait return self.put(item, block=False)
# line 133, in put raise Full


q.get_nowait()
q.get_nowait()
#q.get_nowait() #error occurs
#line 195, in get_nowait return self.get(block=False)
#line 164, in get raise Empty


q.put("AA", True, 5);
q.put("AA", True, 5);
#q.put("AA", True, 5);  # wait 5 second until there is available space, if no space after 5 second, error occur



No comments:

Post a Comment