kopia lustrzana https://github.com/cirospaciari/socketify.py
fixed forking/timing thread
rodzic
31d4eda821
commit
2bfb007ce4
22
main.py
22
main.py
|
@ -430,7 +430,7 @@ class UWSApp:
|
||||||
def run(self):
|
def run(self):
|
||||||
lib.uws_app_run(self.SSL, self.app)
|
lib.uws_app_run(self.SSL, self.app)
|
||||||
return self
|
return self
|
||||||
|
|
||||||
def close(self):
|
def close(self):
|
||||||
if hasattr(self, "socket"):
|
if hasattr(self, "socket"):
|
||||||
if not self.socket == ffi.NULL:
|
if not self.socket == ffi.NULL:
|
||||||
|
@ -460,28 +460,30 @@ def time_thread():
|
||||||
current_http_date = datetime.utcnow().isoformat() + "Z"
|
current_http_date = datetime.utcnow().isoformat() + "Z"
|
||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
|
|
||||||
timing = threading.Thread(target=time_thread, args=())
|
|
||||||
timing.start()
|
|
||||||
|
|
||||||
def plaintext(res, req):
|
def plaintext(res, req):
|
||||||
res.write_header("Date", current_http_date)
|
res.write_header("Date", current_http_date)
|
||||||
res.write_header("Server", "uws.py")
|
res.write_header("Server", "uws.py")
|
||||||
res.write_header("Content-Type", "text/plain")
|
res.write_header("Content-Type", "text/plain")
|
||||||
res.end("Hello, World!")
|
res.end("Hello, World!")
|
||||||
|
|
||||||
|
def run_app():
|
||||||
|
timing = threading.Thread(target=time_thread, args=())
|
||||||
|
timing.start()
|
||||||
|
app = UWSApp()
|
||||||
|
app.get("/", plaintext)
|
||||||
|
app.listen(3000, lambda config: print("Listening on port http://localhost:%s now\n" % str(config.port)))
|
||||||
|
app.run()
|
||||||
|
|
||||||
def create_fork():
|
def create_fork():
|
||||||
n = os.fork()
|
n = os.fork()
|
||||||
# n greater than 0 means parent process
|
# n greater than 0 means parent process
|
||||||
if not n > 0:
|
if not n > 0:
|
||||||
app = UWSApp()
|
run_app()
|
||||||
app.get("/", plaintext)
|
|
||||||
app.listen(3000, lambda config: print("Listening on port http://localhost:%s now\n" % str(config.port)))
|
|
||||||
app.run()
|
|
||||||
|
|
||||||
for index in range(4):
|
for index in range(3):
|
||||||
create_fork()
|
create_fork()
|
||||||
|
|
||||||
|
run_app()
|
||||||
#pip install git+https://github.com/inducer/pycuda.git (submodules are cloned recursively)
|
#pip install git+https://github.com/inducer/pycuda.git (submodules are cloned recursively)
|
||||||
#https://stackoverflow.com/questions/1754966/how-can-i-run-a-makefile-in-setup-py
|
#https://stackoverflow.com/questions/1754966/how-can-i-run-a-makefile-in-setup-py
|
||||||
#https://packaging.python.org/en/latest/tutorials/packaging-projects/
|
#https://packaging.python.org/en/latest/tutorials/packaging-projects/
|
Ładowanie…
Reference in New Issue