Skip to content

Commit

Permalink
alarm task stopped before filter uninstall
Browse files Browse the repository at this point in the history
RaidenService had a race among the alarm task and the filter removal,
that allowed the filter to be uninstall before the next poll callback
was
executed, resulting in exceptions like the following:

JSONRPCClientReplyError: filter not found

This change adds synchronization, requiring the alarm task to
completely stop before the events are removed.
  • Loading branch information
hackaugusto committed Sep 4, 2017
1 parent a52b89a commit d971887
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions raiden/raiden_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -301,18 +301,20 @@ def start_neighbours_healthcheck(self):

def stop(self):
""" Stop the node. """
wait_for = [self.alarm]
wait_for.extend(self.greenlet_task_dispatcher.stop())

self.alarm.stop_async()

wait_for.extend(self.protocol.greenlets)
self.pyethapp_blockchain_events.uninstall_all_event_listeners()

self.protocol.stop_and_wait()

wait_for = [self.alarm]
wait_for.extend(self.protocol.greenlets)
wait_for.extend(self.greenlet_task_dispatcher.stop())
gevent.wait(wait_for)

# Filters must be uninstalled after the alarm task has stopped. Since
# the events are polled by a alarm task callback, if the filters are
# uninstalled before the alarm task is fully stopped the callback
# `poll_blockchain_events` will fail.
self.pyethapp_blockchain_events.uninstall_all_event_listeners()

# save the state after all tasks are done
if self.serialization_file:
save_snapshot(self.serialization_file, self)
Expand Down

0 comments on commit d971887

Please sign in to comment.