@@ -110,11 +110,11 @@ def put(self, obj, block=True, timeout=None):
110
110
def get (self , block = True , timeout = None ):
111
111
if self ._closed :
112
112
raise ValueError (f"Queue { self !r} is closed" )
113
- if self ._shutdown_state .value != _queue_alive :
113
+ if self ._shutdown_state .value == _queue_shutdown_immediate :
114
114
raise ShutDown
115
115
if block and timeout is None :
116
116
with self ._rlock :
117
- if self ._shutdown_state .value != _queue_alive :
117
+ if self ._shutdown_state .value == _queue_shutdown_immediate :
118
118
raise ShutDown
119
119
res = self ._recv_bytes ()
120
120
self ._sem .release ()
@@ -127,18 +127,18 @@ def get(self, block=True, timeout=None):
127
127
if block :
128
128
timeout = deadline - time .monotonic ()
129
129
if not self ._poll (timeout ):
130
- if self ._shutdown_state .value != _queue_alive :
130
+ if self ._shutdown_state .value == _queue_shutdown_immediate :
131
131
raise ShutDown
132
132
raise Empty
133
- if self ._shutdown_state .value != _queue_alive :
133
+ if self ._shutdown_state .value == _queue_shutdown_immediate :
134
134
raise ShutDown
135
135
elif not self ._poll ():
136
136
raise Empty
137
137
res = self ._recv_bytes ()
138
138
self ._sem .release ()
139
139
finally :
140
140
self ._rlock .release ()
141
- if self ._shutdown_state .value == _queue_shutdown :
141
+ if self ._shutdown_state .value == _queue_shutdown_immediate :
142
142
raise ShutDown
143
143
# unserialize the data after having released the lock
144
144
return _ForkingPickler .loads (res )
@@ -342,7 +342,7 @@ def put(self, obj, block=True, timeout=None):
342
342
if self ._closed :
343
343
raise ValueError (f"Queue { self !r} is closed" )
344
344
if self ._shutdown_state .value != _queue_alive :
345
- return
345
+ raise ShutDown
346
346
if not self ._sem .acquire (block , timeout ):
347
347
raise Full
348
348
@@ -355,7 +355,7 @@ def put(self, obj, block=True, timeout=None):
355
355
356
356
def task_done (self ):
357
357
with self ._cond :
358
- if self ._shutdown_state .value != _queue_alive :
358
+ if self ._shutdown_state .value == _queue_shutdown_immediate :
359
359
raise ShutDown
360
360
if not self ._unfinished_tasks .acquire (False ):
361
361
raise ValueError ('task_done() called too many times' )
0 commit comments