I have a celery that makes messages similar to a database:
Class ProcessRequests: Def run (self, batch): q: msg = message for e. Object. Create (Recipient_Number = E. Mobile, Content = Batch Content, Sender = e.contact_owner, billee = Batch.Uz, Sender_Name = Batch.sender_name) Gateway = Gateway.Obiges The gate (pk = 2) msg.send (gateway) then the msg.send (gateway) model is another task that actually sends the message and it Runs: SendMessage (function): name = "send sms" max_retries = 10 default_retry_delay = 3 def run (auto, message_id, gateway_id = none, ** kwargs): logging. Debug ("to send a message.") Then logging some stuff here Debug ("Send Message.") All this works fine (more than 1000 messages were tested), but I have read somewhere that you do not have to work together the chain Nevertheless, it is not Chenning, okay ? Is this example okay in terms of performance?
Send something like this:
Send Diff (self, message): "" "Use this gateway to send a message, if` `DJsiri`` If we have installed, then we believe that they have set up `` cellarard` 'server, and we do not queue for delivery. Otherwise, we will send in-process .. Note: It is too much to run out of this process Recommended, especially if you are sending it as a part of HTTP and ITeS, Since it can take up to 5 seconds per message, it has to be sent. "" If settings 'DjCelli' .INSTALLED_APPS: import sms.tasks sms.tasks.SendMessage.delay (message.pk, self.pk) Other: self._send ( Message)
short version, yes, you are doing the right thing.
Long version: The thing is that you do not want to do anything like this:
@task def something (** Kwargs): # do Some things here are some_elles E.delay (). Get () @ Task Def Som_Alse (** kwargs): # Here's something else will wait for some results from some_else . You may also consider creating a message for a task (so your loop only produces work and does not connect directly to the database).
PS: If you want to track all results from the results of ProcessRequests work, then you can execute them as sub-quantities: This can help you get results group:
No comments:
Post a Comment