Skip to content

Conversation

@rudolfix
Copy link
Collaborator

Description

More signal handling options for typical production cases. See commit log and docs update

@rudolfix rudolfix requested review from VioletM and sh-rp October 24, 2025 13:19
@rudolfix rudolfix self-assigned this Oct 24, 2025
@rudolfix rudolfix added the ci full Use to trigger CI on a PR for full load tests label Oct 24, 2025
@cloudflare-workers-and-pages
Copy link

cloudflare-workers-and-pages bot commented Oct 24, 2025

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
docs accc93b Commit Preview URL

Branch Preview URL
Oct 28 2025, 12:00 AM

@rudolfix rudolfix force-pushed the feat/more-signal-options branch from e69bba7 to 1bfaf20 Compare October 25, 2025 07:53
@rudolfix rudolfix force-pushed the feat/more-signal-options branch from 1bfaf20 to fb44a6a Compare October 25, 2025 08:27
Copy link
Collaborator

@sh-rp sh-rp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool PR!

I have one major question around how the Semaphore works, I am missing something there.

Apart from that, the docs are quite cryptic imho and the config setting intercept_signals is not self-explanatory at all. Maybe handle_signals_gracefully or something like that would be nicer.

- `normalize` step: raises `SignalReceivedException` at certain checkpoints, typically immediately
- `load` step: on a first received signal, it attempts to drain the job pool by not accepting new load jobs but waiting for executing jobs to complete.
On a second signal, default handler is called resulting in KeyboardInterrupt or immediate process termination (SIGTERM)
- `extract` step does not intercept signals and uses default handlers. However it will raise `SignalReceivedException` is `dlt` custom signalling is activated.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To me it is not cleaer what "dlt custom signalling" means

:::

#### Write custom signal handler
You can install your own signal handler. We are working on making the `signals.py` pluggable. Currently you can just disable signal interception globally
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here I would also explain better what "signal interception" means. I know what "intercept_signals" does when reading the code, but if I were only to read the docs, I would not know.

load_info = load()
```

### Allow for graceful shutdown
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe run the grammar checker on this whole block.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah you are right I'll do that :/

self._job_metrics: Dict[str, LoadJobMetrics] = {}
# job completed signalling event (start blocking)
self._done_event = BoundedSemaphore()
self._done_event.acquire()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This I don't understand. You acquire this once on the main thread but every individual job releases it on the job thread? How does this work? I think I am missing some part of this, I would expect an exception if there are more than 2 jobs.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that's actually trivial: semaphore is created in release state so first acquire will just get through. I want first loop in load to sleep. if I do not acquire semaphore right away - it skips. btw. typically you can set if semaphore is released or not (initial value) in constructor. but not in Python apparently

@rudolfix rudolfix force-pushed the feat/more-signal-options branch from 5f7b96b to accc93b Compare October 27, 2025 23:53
@rudolfix rudolfix requested a review from sh-rp October 28, 2025 07:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci full Use to trigger CI on a PR for full load tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants