Comments (4)
Could you post a more detailed reproducer and a traceback? Or maybe add a PR with a test case for this?
from cheroot.
Not very nice, but here is a simple example
from threading import Event, Thread
from flask import Flask
from cheroot.wsgi import Server
from cheroot.workers.threadpool import WorkerThread
app = Flask("sample")
server = Server(("localhost", 5001), app)
stop_done = Event()
in_start = Event()
original_start = WorkerThread
def start(*args, **kwargs):
in_start.set()
stop_done.wait()
original_start(*args, **kwargs)
WorkerThread.start = start
def target():
in_start.wait()
server.stop()
stop_done.set()
thread = Thread(target=target)
thread.start()
server.safe_start()
thread.join()
Stacktrace
Exception in thread Thread-1 (target):
Traceback (most recent call last):
File "/root/.pyenv/versions/3.11.0/lib/python3.11/threading.py", line 1038, in _bootstrap_inner
self.run()
File "/root/.pyenv/versions/3.11.0/lib/python3.11/threading.py", line 975, in run
self._target(*self._args, **self._kwargs)
File "/root/foo.py", line 21, in target
server.stop()
File "/root/venv/lib/python3.11/site-packages/cheroot/server.py", line 2094, in stop
self.requests.stop(self.shutdown_timeout)
File "/root/venv/lib/python3.11/site-packages/cheroot/workers/threadpool.py", line 292, in stop
worker.join(remaining_time)
File "/root/.pyenv/versions/3.11.0/lib/python3.11/threading.py", line 1107, in join
raise RuntimeError("cannot join thread before it is started")
RuntimeError: cannot join thread before it is started
Instead of the monkeypatching, now image that exactly before WorkerThread.start is called a signal occurs. The signal handler in my case will then ask the server to stop. This leads to the original issuue
from cheroot.
I suppose this snipped could be further simplified with
- from flask import Flask
- app = Flask("sample")
- server = Server(("localhost", 5001), app)
+ server = Server(("localhost", 5001), lambda *_, **__: None)
right?
from cheroot.
yes, this also works
from cheroot.
Related Issues (20)
- test_tls_client_auth: previous item was not torn down properly HOT 7
- setuptools_scm_git_archive is obsolete HOT 1
- ssl.SSLZeroReturnError exception on startup with builtin ssl backend python 3.8 or above HOT 14
- test_keepalive_conn_management failure on Solaris. HOT 3
- Drop support for Python 3.7 HOT 1
- LGTM bot is deprecated HOT 2
- pre-commit fails locally on Python 3.11 macOS HOT 4
- `OSError: [Errno 9] Bad file descriptor` on `socket.shutdown(socket.SHUT_RDWR)`
- Serve will do its job even if stop was called before
- Certain SSL failures can result in worker thread termination
- linkcheck job failing due to utcc.utoronto.ca being down HOT 3
- History is full of uninteresting commits HOT 2
- tox -e pre-commit fails attempting to build cryptography < 3.3 HOT 4
- CI checks are overly nitpicky about descriptions. HOT 1
- pre-commit has onerous dependencies HOT 1
- SSL error during _conditional_error will crash worker thread HOT 2
- Failing test with openssl 3.2.0 (test_https_over_http_error) HOT 3
- Host header is not validated HOT 8
- Memory leak when using BuiltinSSLAdapter HOT 3
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 cheroot.