Skip to main content

All Questions

0 votes
0 answers
178 views

Understanding sync_to_async method in Django?

I have never worked with asyncio and/or asynchronous methods with django and am having a little difficulty understanding. I am trying to convert a synchronous utility function (create_email_record) ...
master_j02's user avatar
0 votes
1 answer
384 views

Python Django(?) ORM race conditions

The answer to my question may probably be obvious, but I'd like to find out for myself. I love Django ORM and use it in almost all my projects. I'm currently developing a telegram bot using Pyrogram (...
ltad's user avatar
  • 3
2 votes
1 answer
1k views

Fire & Forget Asyncio

I've been scouring the web to an answer to this question but I can't seem to find an actual answer or maybe i'm just missing it. I'm trying to fire off a post request to start another microservice and ...
A_Lopez's user avatar
  • 49
0 votes
0 answers
776 views

How long does the `httpx.AsyncClient` can "live" without closing the event loop?

I have an endpoint in Django that orchestrates a bunch of API calls to other underlying services. I intend to use a long-lived instance of httpx.AsyncClient - which will be ultimately responsible for ...
Murilo Sitonio's user avatar
0 votes
0 answers
123 views

Celery instead of Async views with asyncio in django

I am new to django! (So basically i am seeking suggestions for this approach). In my project i had so many views and each view had at least 1 database i/o and as all my views are synchronous i find ...
varun_k_21's user avatar
1 vote
0 answers
1k views

You cannot call this from an async context - use a thread or sync_to_async. Django ORM

I wrote the following code: class BookmakerA: def __init__(self) -> None: self.bookmaker = None async def _init(self): self.bookmaker, _ = await Bookmaker.objects....
Sander Bakker's user avatar
0 votes
1 answer
523 views

Django optimize waiting for a response

I'm trying to speed up my Django server which is running let's say 4 processes and for some view, it is making a request to another server which is performing some computation and sending a request to ...
Jakub Swistak's user avatar
0 votes
1 answer
353 views

Python Django - process long running views in the background

What is the best approach to send a long running process to the background in Python when working within the Django framework. Summary: I'm using a Django web app alongside chatGPT to create a certain ...
CoreyRobinson's user avatar
0 votes
1 answer
696 views

Getting SynchronousOnlyOperation while creating an object in async function in django

While running this: async def func(): print("This is async function") Program.objects.create(name="New Program") asyncio.run(func()) Getting this: Error : ...
Rajat Kumar's user avatar
0 votes
0 answers
271 views

Write uploaded file by chunks in an async context

I have a Python async function receiving a django.core.files.uploadedfile.TemporaryUploadedFile from an Django API endpoint, as well as from a Django form. Once this function/coroutine is launched, it ...
bolino's user avatar
  • 1,132
0 votes
0 answers
449 views

how to run tasks in parallel with django async

i'm using daphne as a asgi server, with django. turning my view from sync to async was relatively simple, since i could use @sync_to_async at the ORM part. the problem is, some service of mine is like ...
gabriel119435's user avatar
4 votes
1 answer
1k views

Python - Single thread executor already being used, would deadlock

I'm trying to create an async view that accesses the DB and returns data with two separate queries. @sync_to_async def get_tweets(request): return (Tweet.objects. annotate(full_text=...
Christinerex's user avatar
3 votes
1 answer
7k views

how to run async function in Threadpoolexecutor in python

I have an async get_forecastweather function which gives me JSON weather data, I understand that we can't execute the async function inside sync, but how do i do it inside a separate thread, need help,...
Atif Shafi's user avatar
  • 1,204
0 votes
0 answers
439 views

How to use async Django views without sleep?

I'm working on a Django view where I have two time-consuming operations that could be run in parallel (reads from a remote DB). I have created an async view but, presumably because I have no sleep ...
Ariel's user avatar
  • 3,611
1 vote
2 answers
923 views

I'm not sure why im getting this async error in python

I managed to get my api request asynchronous but then received this error when trying to implement it into the main project. What does this mean that I have done wrong? ERROR Exception has occurred: ...
ruffishkimbr's user avatar

15 30 50 per page