File tree 2 files changed +8
-0
lines changed 2 files changed +8
-0
lines changed Original file line number Diff line number Diff line change @@ -507,6 +507,8 @@ Synchronous methods (immediate return):
507
507
* ` put_nowait ` Arg: the object to put on the queue. Raises ` IndexError ` if the
508
508
queue is full. If the calling code ignores the exception the oldest item in
509
509
the queue will be overwritten. In some applications this can be of use.
510
+ * ` peek ` No arg. Returns oldest entry without removing it from the queue. This
511
+ is a superset of the CPython compatible methods.
510
512
511
513
Asynchronous methods:
512
514
* ` put ` Arg: the object to put on the queue. If the queue is full, it will
Original file line number Diff line number Diff line change @@ -39,6 +39,12 @@ def get_nowait(self): # Remove and return an item from the queue.
39
39
self ._evget .clear ()
40
40
return r
41
41
42
+ def peek (self ): # Return oldest item from the queue without removing it.
43
+ # Return an item if one is immediately available, else raise QueueEmpty.
44
+ if self .empty ():
45
+ raise IndexError
46
+ return self ._q [self ._ri ]
47
+
42
48
def put_nowait (self , v ):
43
49
self ._q [self ._wi ] = v
44
50
self ._evput .set () # Schedule any tasks waiting on get
You can’t perform that action at this time.
0 commit comments