Skip to content

Commit 9f7affe

Browse files
committed
Prevent race condition in connection processing
Fixes #198
1 parent 78baa41 commit 9f7affe

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

cheroot/workers/threadpool.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,13 +108,14 @@ def run(self):
108108
return
109109

110110
self.conn = conn
111-
if self.server.stats['Enabled']:
111+
is_stats_enabled = self.server.stats['Enabled']
112+
if is_stats_enabled:
112113
self.start_time = time.time()
113114
try:
114115
conn.communicate()
115116
finally:
116117
conn.close()
117-
if self.server.stats['Enabled']:
118+
if is_stats_enabled:
118119
self.requests_seen += self.conn.requests_seen
119120
self.bytes_read += self.conn.rfile.bytes_read
120121
self.bytes_written += self.conn.wfile.bytes_written

0 commit comments

Comments
 (0)