Unable to exit normally when fast is set to True and use nextcord(discord.py).
See original GitHub issueDescribe the problem
When I use fast=True
on sanic.Sanic
and use nextcord that forked discord.py and I stop program by Ctrl + C, I keep getting this error and canβt quit.
What could be the cause of this?
[2022-01-22 08:41:01 +0900] [4349] [INFO] Received signal SIGTERM. Shutting down.
Traceback (most recent call last):
File "/Users/tasuren/.pyenv/versions/3.9.7/lib/python3.9/logging/__init__.py", line 1086, in emit
stream.write(msg + self.terminator)
RuntimeError: reentrant call inside <_io.BufferedWriter name='<stdout>'>
Call stack:
[2022-01-22 08:41:01 +0900] [4348] [INFO] Received signal SIGTERM. Shutting down.
File "/Users/tasuren/Documents/src/python/rt/rt-backend/main.py", line 63, in <module>
app.run(**secret["app"])
File "/Users/tasuren/.pyenv/versions/3.9.7/lib/python3.9/site-packages/sanic/app.py", line 1206, in run
serve_multiple(server_settings, workers)
File "/Users/tasuren/.pyenv/versions/3.9.7/lib/python3.9/site-packages/sanic/server/runners.py", line 264, in serve_multiple
process.start()
File "/Users/tasuren/.pyenv/versions/3.9.7/lib/python3.9/multiprocessing/process.py", line 121, in start
self._popen = self._Popen(self)
File "/Users/tasuren/.pyenv/versions/3.9.7/lib/python3.9/multiprocessing/context.py", line 277, in _Popen
return Popen(process_obj)
File "/Users/tasuren/.pyenv/versions/3.9.7/lib/python3.9/multiprocessing/popen_fork.py", line 19, in __init__
self._launch(process_obj)
File "/Users/tasuren/.pyenv/versions/3.9.7/lib/python3.9/multiprocessing/popen_fork.py", line 71, in _launch
code = process_obj._bootstrap(parent_sentinel=child_r)
File "/Users/tasuren/.pyenv/versions/3.9.7/lib/python3.9/multiprocessing/process.py", line 315, in _bootstrap
self.run()
File "/Users/tasuren/.pyenv/versions/3.9.7/lib/python3.9/multiprocessing/process.py", line 108, in run
self._target(*self._args, **self._kwargs)
File "/Users/tasuren/.pyenv/versions/3.9.7/lib/python3.9/site-packages/sanic/server/runners.py", line 130, in serve
loop.run_until_complete(app._server_event("init", "before"))
File "/Users/tasuren/.pyenv/versions/3.9.7/lib/python3.9/site-packages/sanic/server/runners.py", line 254, in <lambda>
signal_func(SIGINT, lambda s, f: sig_handler(s, f))
File "/Users/tasuren/.pyenv/versions/3.9.7/lib/python3.9/site-packages/sanic/server/runners.py", line 250, in sig_handler
logger.info("Received signal %s. Shutting down.", Signals(signal).name)
File "/Users/tasuren/.pyenv/versions/3.9.7/lib/python3.9/logging/__init__.py", line 1446, in info
self._log(INFO, msg, args, **kwargs)
File "/Users/tasuren/.pyenv/versions/3.9.7/lib/python3.9/logging/__init__.py", line 1589, in _log
self.handle(record)
File "/Users/tasuren/.pyenv/versions/3.9.7/lib/python3.9/logging/__init__.py", line 1599, in handle
self.callHandlers(record)
File "/Users/tasuren/.pyenv/versions/3.9.7/lib/python3.9/logging/__init__.py", line 1661, in callHandlers
hdlr.handle(record)
File "/Users/tasuren/.pyenv/versions/3.9.7/lib/python3.9/logging/__init__.py", line 952, in handle
self.emit(record)
File "/Users/tasuren/.pyenv/versions/3.9.7/lib/python3.9/logging/__init__.py", line 1083, in emit
msg = self.format(record)
File "/Users/tasuren/.pyenv/versions/3.9.7/lib/python3.9/logging/__init__.py", line 927, in format
return fmt.format(record)
File "/Users/tasuren/.pyenv/versions/3.9.7/lib/python3.9/logging/__init__.py", line 665, in format
record.asctime = self.formatTime(record, self.datefmt)
File "/Users/tasuren/.pyenv/versions/3.9.7/lib/python3.9/logging/__init__.py", line 602, in formatTime
s = time.strftime(datefmt, ct)
File "/Users/tasuren/.pyenv/versions/3.9.7/lib/python3.9/site-packages/sanic/server/runners.py", line 255, in <lambda>
signal_func(SIGTERM, lambda s, f: sig_handler(s, f))
File "/Users/tasuren/.pyenv/versions/3.9.7/lib/python3.9/site-packages/sanic/server/runners.py", line 250, in sig_handler
logger.info("Received signal %s. Shutting down.", Signals(signal).name)
File "/Users/tasuren/.pyenv/versions/3.9.7/lib/python3.9/logging/__init__.py", line 1446, in info
self._log(INFO, msg, args, **kwargs)
File "/Users/tasuren/.pyenv/versions/3.9.7/lib/python3.9/logging/__init__.py", line 1589, in _log
self.handle(record)
File "/Users/tasuren/.pyenv/versions/3.9.7/lib/python3.9/logging/__init__.py", line 1599, in handle
self.callHandlers(record)
File "/Users/tasuren/.pyenv/versions/3.9.7/lib/python3.9/logging/__init__.py", line 1661, in callHandlers
hdlr.handle(record)
File "/Users/tasuren/.pyenv/versions/3.9.7/lib/python3.9/logging/__init__.py", line 952, in handle
self.emit(record)
File "/Users/tasuren/.pyenv/versions/3.9.7/lib/python3.9/logging/__init__.py", line 1083, in emit
msg = self.format(record)
File "/Users/tasuren/.pyenv/versions/3.9.7/lib/python3.9/logging/__init__.py", line 927, in format
return fmt.format(record)
File "/Users/tasuren/.pyenv/versions/3.9.7/lib/python3.9/logging/__init__.py", line 665, in format
record.asctime = self.formatTime(record, self.datefmt)
File "/Users/tasuren/.pyenv/versions/3.9.7/lib/python3.9/logging/__init__.py", line 600, in formatTime
ct = self.converter(record.created)
File "/Users/tasuren/.pyenv/versions/3.9.7/lib/python3.9/site-packages/sanic/server/runners.py", line 255, in <lambda>
signal_func(SIGTERM, lambda s, f: sig_handler(s, f))
File "/Users/tasuren/.pyenv/versions/3.9.7/lib/python3.9/site-packages/sanic/server/runners.py", line 252, in sig_handler
os.kill(process.pid, SIGTERM)
File "/Users/tasuren/.pyenv/versions/3.9.7/lib/python3.9/site-packages/sanic/server/runners.py", line 255, in <lambda>
signal_func(SIGTERM, lambda s, f: sig_handler(s, f))
File "/Users/tasuren/.pyenv/versions/3.9.7/lib/python3.9/site-packages/sanic/server/runners.py", line 250, in sig_handler
logger.info("Received signal %s. Shutting down.", Signals(signal).name)
File "/Users/tasuren/.pyenv/versions/3.9.7/lib/python3.9/logging/__init__.py", line 1446, in info
self._log(INFO, msg, args, **kwargs)
File "/Users/tasuren/.pyenv/versions/3.9.7/lib/python3.9/logging/__init__.py", line 1589, in _log
self.handle(record)
File "/Users/tasuren/.pyenv/versions/3.9.7/lib/python3.9/logging/__init__.py", line 1599, in handle
self.callHandlers(record)
File "/Users/tasuren/.pyenv/versions/3.9.7/lib/python3.9/logging/__init__.py", line 1661, in callHandlers
hdlr.handle(record)
File "/Users/tasuren/.pyenv/versions/3.9.7/lib/python3.9/logging/__init__.py", line 952, in handle
self.emit(record)
File "/Users/tasuren/.pyenv/versions/3.9.7/lib/python3.9/logging/__init__.py", line 1083, in emit
msg = self.format(record)
File "/Users/tasuren/.pyenv/versions/3.9.7/lib/python3.9/logging/__init__.py", line 927, in format
return fmt.format(record)
File "/Users/tasuren/.pyenv/versions/3.9.7/lib/python3.9/logging/__init__.py", line 665, in format
record.asctime = self.formatTime(record, self.datefmt)
File "/Users/tasuren/.pyenv/versions/3.9.7/lib/python3.9/logging/__init__.py", line 600, in formatTime
ct = self.converter(record.created)
File "/Users/tasuren/.pyenv/versions/3.9.7/lib/python3.9/site-packages/sanic/server/runners.py", line 255, in <lambda>
signal_func(SIGTERM, lambda s, f: sig_handler(s, f))
File "/Users/tasuren/.pyenv/versions/3.9.7/lib/python3.9/site-packages/sanic/server/runners.py", line 250, in sig_handler
logger.info("Received signal %s. Shutting down.", Signals(signal).name)
File "/Users/tasuren/.pyenv/versions/3.9.7/lib/python3.9/logging/__init__.py", line 1446, in info
self._log(INFO, msg, args, **kwargs)
File "/Users/tasuren/.pyenv/versions/3.9.7/lib/python3.9/logging/__init__.py", line 1577, in _log
fn, lno, func, sinfo = self.findCaller(stack_info, stacklevel)
File "/Users/tasuren/.pyenv/versions/3.9.7/lib/python3.9/site-packages/sanic/server/runners.py", line 255, in <lambda>
signal_func(SIGTERM, lambda s, f: sig_handler(s, f))
File "/Users/tasuren/.pyenv/versions/3.9.7/lib/python3.9/site-packages/sanic/server/runners.py", line 250, in sig_handler
logger.info("Received signal %s. Shutting down.", Signals(signal).name)
File "/Users/tasuren/.pyenv/versions/3.9.7/lib/python3.9/logging/__init__.py", line 1446, in info
self._log(INFO, msg, args, **kwargs)
File "/Users/tasuren/.pyenv/versions/3.9.7/lib/python3.9/logging/__init__.py", line 1589, in _log
self.handle(record)
File "/Users/tasuren/.pyenv/versions/3.9.7/lib/python3.9/logging/__init__.py", line 1599, in handle
self.callHandlers(record)
File "/Users/tasuren/.pyenv/versions/3.9.7/lib/python3.9/logging/__init__.py", line 1661, in callHandlers
hdlr.handle(record)
File "/Users/tasuren/.pyenv/versions/3.9.7/lib/python3.9/logging/__init__.py", line 952, in handle
self.emit(record)
File "/Users/tasuren/.pyenv/versions/3.9.7/lib/python3.9/logging/__init__.py", line 1083, in emit
msg = self.format(record)
File "/Users/tasuren/.pyenv/versions/3.9.7/lib/python3.9/logging/__init__.py", line 927, in format
return fmt.format(record)
File "/Users/tasuren/.pyenv/versions/3.9.7/lib/python3.9/logging/__init__.py", line 665, in format
record.asctime = self.formatTime(record, self.datefmt)
File "/Users/tasuren/.pyenv/versions/3.9.7/lib/python3.9/logging/__init__.py", line 600, in formatTime
ct = self.converter(record.created)
File "/Users/tasuren/.pyenv/versions/3.9.7/lib/python3.9/site-packages/sanic/server/runners.py", line 255, in <lambda>
signal_func(SIGTERM, lambda s, f: sig_handler(s, f))
File "/Users/tasuren/.pyenv/versions/3.9.7/lib/python3.9/site-packages/sanic/server/runners.py", line 250, in sig_handler
logger.info("Received signal %s. Shutting down.", Signals(signal).name)
File "/Users/tasuren/.pyenv/versions/3.9.7/lib/python3.9/logging/__init__.py", line 1446, in info
self._log(INFO, msg, args, **kwargs)
File "/Users/tasuren/.pyenv/versions/3.9.7/lib/python3.9/logging/__init__.py", line 1589, in _log
self.handle(record)
File "/Users/tasuren/.pyenv/versions/3.9.7/lib/python3.9/logging/__init__.py", line 1599, in handle
self.callHandlers(record)
File "/Users/tasuren/.pyenv/versions/3.9.7/lib/python3.9/logging/__init__.py", line 1661, in callHandlers
hdlr.handle(record)
File "/Users/tasuren/.pyenv/versions/3.9.7/lib/python3.9/logging/__init__.py", line 952, in handle
self.emit(record)
File "/Users/tasuren/.pyenv/versions/3.9.7/lib/python3.9/logging/__init__.py", line 1086, in emit
stream.write(msg + self.terminator)
File "/Users/tasuren/.pyenv/versions/3.9.7/lib/python3.9/site-packages/sanic/server/runners.py", line 255, in <lambda>
signal_func(SIGTERM, lambda s, f: sig_handler(s, f))
File "/Users/tasuren/.pyenv/versions/3.9.7/lib/python3.9/site-packages/sanic/server/runners.py", line 250, in sig_handler
logger.info("Received signal %s. Shutting down.", Signals(signal).name)
Message: 'Received signal %s. Shutting down.'
Arguments: ('SIGTERM',)
[2022-01-22 08:41:01 +0900] [4351] [INFO] Received signal SIGTERM. Shutting down.
Code snippet
Iβm not sure where to point you, so Iβve included the URL of the repository where all the code is located.
https://github.com/RT-Team/rt-backend
Expected behavior I want to make sure that it exits normally.
Environment (please complete the following information):
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Sanic v21.12.1 β
β Goin' Fast @ http://0.0.0.0:80 β
βββββββββββββββββββββββββ¬βββββββββββββββββββββββββββββββββββββββ€
β β mode: production, single worker β
β ββββ βββββ ββ β server: sanic β
β ββ β python: 3.9.7 β
β ββββββββ ββββ β platform: macOS-12.1-arm64-arm-64bit β
β ββ β packages: sanic-routing==0.7.2 β
β ββββ βββββββββ β β
β β β
β Build Fast. Run Fast. β β
βββββββββββββββββββββββββ΄βββββββββββββββββββββββββββββββββββββββ
Issue Analytics
- State:
- Created 2 years ago
- Comments:7 (3 by maintainers)
Top Results From Across the Web
All you need to know about Buttons in Discord.py & Pycord
This is the Ultimate Python Guide on Buttons with Discord. py or Pycord. In this video, I talk about how to create buttons...
Read more >Discord.py is dead. What now? - YouTube
In this video, I talk about what happened to discord. py, why it got discontinued, and it's alternatives. I also showcase the Pycord...
Read more >Discord.py Button responses interaction failed after a certain ...
The button does the same thing whether using discord.py (2.0) or pycord. Nothing hits the console. It's as if the button click isn't...
Read more >API Reference - discord.py
This applies to the ratelimit handling code. If this is set to True , the default, then the library uses the time to...
Read more >Bot not going offline when disconnecting - Discord Support
I'm developing it in Python, using the "discord.py" library. ... Below is a quick copy you can spin up to demonstrate this bug:...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
You should use the main process listeners then.
I see. I would like to run the Bot in a separate process. Thank you very much for your answer.