Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix exceptions causing end requests without start requests (and then causing 100% cpu on lock.acquire... maybe) #16

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 6 additions & 8 deletions haufe/requestmonitoring/monitor.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,14 +56,13 @@ def account_request(request, end):
ticket = ITicket(request)
id = ticket.id
info = str(IInfo(request))
_lock.acquire()
try:
with _lock:
if end:
del _state[id]
if id in _state:
# exception in another subscriber can cause an end without a start
del _state[id]
else:
_state[id] = Request(id, info, request, ticket.time, get_ident())
finally:
_lock.release()


class _Monitor:
Expand All @@ -77,9 +76,8 @@ def run(self):
log.info('RequestMonitor started')
while 1:
sleep(self.period)
_lock.acquire()
pending = _state.copy()
_lock.release()
with _lock:
pending = _state.copy()
if not pending:
continue
monitorTime = time()
Expand Down