Open
Conversation
Fix several roadblocks preventing usage of cmping as library: Changes: - Add CMPingError exception, replace sys.exit(1) with raise CMPingError() - Add collection of result tuples in Pinger.results - Return times of account setup, group join and message time from Pinger - Add accounts_dir parameter to perform_ping() to allow callers to isolate concurrent probes in separate DB directories, avoiding the deltachat-rpc-server exclusive lock - Add timeout support to Pinger
Author
|
Title got mixed up. This is for the chatmail prober, which is almost ready. |
Previously wait_all_online blocked indefinitely on wait_for_event(), making it impossible to enforce a timeout from the caller. Now it accepts a timeout parameter and polls the account event queue with a 1s granularity, raising CMPingError if the deadline is exceeded. The timeout is propagated throughout. Thread cleanup improvements: - Store Pinger._send_thread so it can be joined after the ping loop preventing the thread from running orphaned after the deadline - Wrap receiver thread joins in a try/finally block in Pinger.receive() (cmping.py:985) so threads are always cleaned up even if the deadline fires or an exception occurs
receiver_thread previously called receiver.wait_for_event(), which internally blocks on queue.Queue.get() with no timeout. After Rpc.close() terminates the rpc-server subprocess and stops the events_loop, nothing puts a sentinel in the account event queues, so every receiver_thread blocked indefinitely. With N^2 pairs and multiple probe rounds, these daemon threads accumulated in threading._dangling. When a new probe tried to fork deltachat-rpc-server, _after_fork called threads.update(_dangling) in the child, which OOM'd because the set had grown to thousands of entries. Symptoms: MemoryError + "can't start new thread" mid-round. Fix: replace the blocking wait_for_event() call with a account_queue.get(timeout=1.0) loop that checks stop_event. The finally block in receive() sets stop_event before joining, so threads exit within ~1s instead of blocking until process exit.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fix several roadblocks preventing usage of cmping as library:
Changes:
isolate concurrent probes in separate DB directories, avoiding the
deltachat-rpc-server exclusive lock