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

flask main thread is hang ,not handler request #41

Closed
chestarss opened this issue May 3, 2017 · 5 comments
Closed

flask main thread is hang ,not handler request #41

chestarss opened this issue May 3, 2017 · 5 comments
Labels

Comments

@chestarss
Copy link

chestarss commented May 3, 2017

#scheduler.py
JOBS = [ { 'id': 'just test', 'func': '__builtin__:print', 'args': ('test .......',), 'trigger': 'interval', 'seconds': 5, } ]
#runserver.py
from flask import Flask
from flask_apscheduler import APScheduler
app = Flask('myapp')
app.config.from_pyfile('./scheduler.py')
apscheduler = APScheduler(app=app)
apscheduler.start()
app.run()

##thread info
###:~$ sudo ps H -C python -o 'pid tid cmd'
PID TID CMD
19690 19690 python runserver.py
19690 19699 python runserver.py
19690 19700 python runserver.py
19690 19701 python runserver.py

the apscheduler can execute, but flask can not handler http request

port 5000 open and listening, when i curl localhost:5000 , it will block forever.

@viniciuschiele
Copy link
Owner

viniciuschiele commented May 3, 2017

what does your Flask endpoint do?

APScheduler runs on its own thread, I don't see how it could happen.

@chestarss
Copy link
Author

chestarss commented May 3, 2017

ps H -C python -o 'pid tid cmd'
PID TID CMD
26657 26657 python runserver.py
26657 26664 python runserver.py
26657 26665 python runserver.py
26657 26666 python runserver.py

sudo strace -p 26664
Process 26664 attached - interrupt to quit
futex(0x7f64a9ae02bc, FUTEX_WAIT_PRIVATE, 1, NULL

26665 and 26666 same sa 26664

@chestarss
Copy link
Author

chestarss commented May 3, 2017

sudo strace -p 26657
Process 26657 attached - interrupt to quit
select(0, NULL, NULL, NULL, {0, 33562}) = 0 (Timeout)
gettimeofday({1493822932, 124044}, NULL) = 0
select(0, NULL, NULL, NULL, {0, 50000}) = 0 (Timeout)
gettimeofday({1493822932, 174338}, NULL) = 0
select(0, NULL, NULL, NULL, {0, 50000}) = 0 (Timeout)
....
loop like this

@viniciuschiele
Copy link
Owner

Are you sure the issue is not in the Flask endpoint? Can you post entire code?

@viniciuschiele
Copy link
Owner

Feel free to open this issue again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants