[tor-dev] Raising exceptions in add_event_listener() threads (was Re: HSv3 descriptor work in stem)

George Kadianakis desnacked at riseup.net
Wed Nov 27 16:04:41 UTC 2019


Hello Damian (and list),

here is another question about an issue I have encountered while
developing onionbalance v3.

In particular, I'm fetching HS descriptors using HSFETCH and then adding
an add_event_listener() event to a function that does the descriptor
parsing and handling as follows:

        controller.add_event_listener(handle_new_desc_content_event, EventType.HS_DESC_CONTENT)

The problem is that the handle_new_desc_content_event() callback has
grown to a non-trivial size and complexity, since it needs to parse the
descriptor, put it in the right places, and tick off the right
checkboxes.

Since its size has increased, so has the number of bugs and errors that
are appearing during development. The problem is that because the
callback is running on a separate thread (?) any errors and exceptions
that get raised in that thread never surface to the my console and hence
I don't see them. This means that I need to do very tedious printf
debugging to find the exact place and type of error everytime something
happens.

What's the proper way to do debugging and development in callbacks like
that? Is there a way to make the exceptions float back to the main
thread or something? Or any other tips?

Thanks! :)



More information about the tor-dev mailing list