210 questions
Score of 0
0 answers
121 views
How do I cleanly stop a sanic server without getting errors related to websocket closing?
I have a python sanic website - I'm using pywebview to display it - when I close the pywebview window, I have a watcher which is doing an "app.stop"
that works beautifully except I always ...
Score of 0
1 answer
98 views
How to download a very big zip file on the fly using Sanic?
I am working on a Python app which uses Sanic and I need to download a very big archive (10 GB).
I am using zipstream to create the archive on the fly and then stream it (Sanic has support for ...
Score of 1
0 answers
51 views
python sanic framework Listeners doesn't work
from loguru import logger
from sanic import Sanic
app = Sanic(__name__)
@app.before_server_start
async def start(*_):
logger.info("Server starting...")
@app.before_server_stop
async ...
Score of 0
1 answer
596 views
The "context has already been set" error that occurs after importing a written Sanic program into another program
Here, I must clarify that English is not my native language. If there are any grammar errors, please forgive me.
python version: 3.10
Sanic-Cors version: 2.2.0
sanic version: 24.6.0
OS: Win 11
I ...
Score of 0
1 answer
187 views
Prometheus metrics in Sanic
I'm trying to add metrics to my Sanic app.
Prometheus provides Python client running as ASGI app - https://prometheus.github.io/client_python/exporting/http/asgi/ .
The question is how to run 2 ASGI ...
Score of 0
2 answers
59 views
Ignoring request for not matching predefined routes
I have some Sanic Python app code where following routes are defined:
def create_inspector(app):
inspector = Sanic(configure_logging=False)
inspector.config['KEEP_ALIVE'] = False
...
Score of 1
0 answers
52 views
How to change variable inside Inspector app.config w/ Sanic
I want to change the variable in the config. which is in app.config.var. It is possible to by using the Inspector change the config. variable data? I just want to use sanic commands to do so.
class ...
Score of 0
0 answers
446 views
RuntimeError: Start method 'spawn' was requested, but 'fork' was already set
I'm trying to create a Sanic server for Nemo ASR. It seems Nemo uses some fork method, while Sanic requires spawn.
I've tried various ways to fix it but haven't been able to resolve the issue. I ...
Score of 0
0 answers
204 views
Stripe Payments to handle Negative Payments
Title: Handling Negative Payments in Stripe for Retainer Payments
Question:
I am currently integrating Stripe into my payment system, where I accept payments from customers online. Additionally, I ...
Score of 1
1 answer
137 views
sanic+tortoise-orm, A worker process was unable to process subsequent requests due to asyncio.exceptions.CancelledError
await Students.filter(id_nunmber = data.id_nunmber, deleted = False).first()
When I execute the above code line without an index, timeout raises the asyncio error:
[2024-01-13 14:03:56,180] [sanic....
Score of 0
0 answers
257 views
Rate limit API requests in Sanic and append remaining number to response
I am trying to implement rate limiting for requests in Sanic. Unfortunately, the sanic-limiter package on PyPI has not been maintained for years and is not working with current Sanic versions.
I found ...
Score of 0
1 answer
119 views
Obtaining ID of Sanic Session
I'm placing session data in the Sanic in-memory session using the following code:
app = Sanic.get_app()
Session(app, interface=InMemorySessionInterface())
request.ctx.session['foo'] = 'bar'
How do I ...
Score of 0
1 answer
217 views
Handling Twilio Connection Errors
How do I handle connection errors using the Twilio console? I have Twilio working with Sanic python and some connection errors are very difficult to diagnose in the application. When an error of this ...
Score of 0
1 answer
278 views
Function Not Found in Sanic Server
In Sanic server, a have a function defined in a file called controller.py with path /views/controller.py. My Sanic app is created in main.py at the root level (/) and can't find this function. The ...
Score of 0
1 answer
162 views
How to log request start in Sanic?
Sanic has access logging but in fact it logs the response, that is, it fires a message when the request processing has been already completed.
But is it possible to log the request's start, before the ...