question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. ItΒ collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Unable to exit normally when fast is set to True and use nextcord(discord.py).

See original GitHub issue

Describe 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:closed
  • Created 2 years ago
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
ahopkinscommented, Jan 24, 2022

You should use the main process listeners then.

0reactions
tasurencommented, Jan 23, 2022

I see. I would like to run the Bot in a separate process. Thank you very much for your answer.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found