Comments (6)
Does it work if you pass use_threads=True
to the Worker
class?
I don't have access to an M1 Mac so I can't debug this. Python support in 3.9.1 is experimental only. Are you able to test on one of the Python 3.10 alphas?
from faktory_worker_python.
Does it work if you pass
use_threads=True
to theWorker
class?
Yes it did.
I don't have access to an M1 Mac so I can't debug this. Python support in 3.9.1 is experimental only. Are you able to test on one of the Python 3.10 alphas?
I'm installing everything via brew. I will check if it's available and let you know.
from faktory_worker_python.
I haven't had the time to install 3.10 alphas but brew has 3.8 that runs on the M1. One of my tests I managed to get this error:
RuntimeError: An attempt has been made to start a new process before the current process has finished its bootstrapping phase. This probably means that you are not using fork to start your child processes and you have forgotten to use the proper idiom in the main module: if name == 'main': freeze_support() ... The "freeze_support()" line can be omitted if the program is not going to be frozen to produce an executable.
So I modified it the sample code to:
from faktory import Worker
def your_function(x, y):
print("your_function")
return x + y
if __name__ == '__main__':
w = Worker(queues=['default'], concurrency=1, use_threads=False)
w.register('test', your_function)
print("after_register")
w.run() # runs until control-c or worker shutdown from Faktory web UI
And it works now (the sample code, but sadly not mine yet). Does this give you any ideas on where the issue could lie or where I can investigate further?
Thank you.
from faktory_worker_python.
Forgot to mention that adding that if
makes the sample code also work under 3.9.
from faktory_worker_python.
If I understand correctly, adding if __name__ == '__main__':
fixes the sample code, but not your production code? If so, I'll update the readme.
Could you try adding:
multiprocessing.set_start_method("fork", force=True)
and see if that helps at all?
from faktory_worker_python.
multiprocessing.set_start_method("fork", force=True)
I changed that and some jobs run, others fail with a BrokenPipe [ErrNo 32]
error (which is shown in Faktory's UI). This is the code that I'm currently running (as a test case):
import sys
from faktory import Worker
import time
import logging
import os
import multiprocessing
multiprocessing.set_start_method("fork", force=True)
print("after import")
def myfunc(phone, amount, params = {}):
time.sleep(1)
print("myfunc")
if __name__ == '__main__':
print("entering main")
w = Worker(queues=['foo'], concurrency=3)
w.register('FooJob', myfunc)
w.run()
I tried changing the concurrency to 1, but the effect was the same. Sometimes it runs, other times I get the BrokenPipe error.
from faktory_worker_python.
Related Issues (20)
- worker job id HOT 2
- Exception when pushing a job
- If a job gets terminated by the OS (out of memory exception), a broken process exception occurs which is not caught properly.
- i/o timeout Closing connection
- worker thread got OSError: [WinError 6] The handle is invalid when stop worker from Web UI
- Release 1.0
- Add support for sending exceptions to Sentry HOT 5
- Worker crashes if there's an error when fetching new jobs HOT 1
- Getting INFO times out after starting a lot of workers HOT 2
- Cannot install version 0.5.0 via pip HOT 3
- ImportError: cannot import name 'BrokenThreadPool' for python version less than 3.7 HOT 1
- Flag version >0.5 to only be python 3.7+ compatible HOT 2
- Batch Support HOT 3
- How to use the `at` argument in queue? HOT 1
- Worker heartbeat crashes with "type 'NoneType' is not iterable" HOT 1
- Remove references to `priority` as a job argument
- FaktoryConnectionResetError in Connection.reply
- AttributeError: Can't pickle local object 'ETL_task.<locals>.task' HOT 6
- Explaination on the thread execution model HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from faktory_worker_python.