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

silverback worker does not use independent processes per worker #81

Open
fubuloubu opened this issue May 7, 2024 · 4 comments
Open
Labels
bug Something isn't working

Comments

@fubuloubu
Copy link
Member

fubuloubu commented May 7, 2024

What went wrong?

When testing with silverback worker -w 3 we noticed that it does not use separate process IDs per worker:

$ silverback worker -w 3 example:app ...
...
SUCCESS: Loaded Silverback App:
  ...
worker_startup process ID 128903
worker_startup process ID 128903
worker_startup process ID 128903

(using os.getpid to print the process ID)

How can it be fixed?

Debug cli implementation of silverback worker

def worker(cli_ctx, account, workers, max_exceptions, shutdown_timeout, path):
app = import_from_string(path)
asyncio.run(run_worker(app.broker, worker_count=workers, shutdown_timeout=shutdown_timeout))

@fubuloubu fubuloubu added the bug Something isn't working label May 7, 2024
Copy link

linear bot commented May 7, 2024

@fubuloubu
Copy link
Member Author

fubuloubu commented May 7, 2024

More testing showing thread ID:

SUCCESS: Loaded Silverback App:
  ...
worker_startup process ID 132726 thread ID 132726
worker_startup process ID 132726 thread ID 132726
worker_startup process ID 132726 thread ID 132726
INFO: Found cached value ...
app_startup process ID 132726 thread ID 132908
SUCCESS: app_startup - 0.000s (0.0%)
exec_block process ID 132726 thread ID 132908
exec_event1 process ID 132726 thread ID 132726
SUCCESS: exec_block[...]
SUCCESS: exec_event1[...]
exec_event1 process ID 132726 thread ID 132726
SUCCESS: exec_event1[...]
exec_event1 process ID 132726 thread ID 132726
exec_block process ID 132726 thread ID 132908
SUCCESS: exec_block[...]
SUCCESS: exec_event1[...]
exec_event1 process ID 132726 thread ID 132726
Exception found while executing function:  ...
ERROR: exec_event1[...]
exec_event1 process ID 132726 thread ID 132726
SUCCESS: exec_event1[...]
exec_event1 process ID 132726 thread ID 132726
exec_block process ID 132726 thread ID 132908
SUCCESS: exec_block[...]
SUCCESS: exec_event1[...]
app_shutdown process ID 132726 thread ID 132908
SUCCESS: app_shutdown - 0.000s (0.0%)
exec_event1 process ID 132726 thread ID 132726
SUCCESS: exec_event1[...]
^CShutting down the broker.
worker_shutdown process ID 132726 thread ID 132726

@mikeshultz
Copy link
Contributor

Ah, I completely forgot I sort of reimplemented this. Though I mostly recall copying it from TaskIQ's code. Still the same issue with threads though, no?

@fubuloubu
Copy link
Member Author

Ah, I completely forgot I sort of reimplemented this. Though I mostly recall copying it from TaskIQ's code. Still the same issue with threads though, no?

It does seem to use separate threads, although I think it's a bit bound by how we do handle the event/block streams in the runner

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants