Celery execution time - celery

I already have an email_sender function using Celery; each email takes 3 seconds to send, and i want to improve my function.
so i need Celery to do something like this:
send email_num[1:500] ---> each email send in 20 second send email_num[500:1500] ---> each email send in 15 second send email_num[1500:5000] ---> each email send in 10 second send email_num[5000:] ---> each email send in 5 second
is there any solution?
I tried to set dynamic time for a task.

Related

How to specify the custom profile to send packet for Moongen?

I'm trying to send multiples packets to test a server , but i need to send different traffic pattern ( send IPv4,ICMP,Ipv6...) but i can't even specify one type when sending the streams
[EDIT-1]
CMD: ./build/MoonGen ./packetgen.lua -tx 0 -rx 1
packetgen.lua is the default script present in LYA folder of Moongen

Can google apps script time-based trigger cause this problem: "554 5.4.6 Too many hops 53 (50 max):"?

Hello I have a google docs document where I installed a simple emailing code on as follows:
function sendMail() {
var file = DriveApp.getFileById('XXXXXXXX');
var recipients = "mymail#group1.com" + "mymail#group2.com" + "mymail#group3.com";
MailApp.sendEmail(recipients, 'Daily Notes', 'Please see file Attached.', {
name: file.getName(),
attachments: [file.getAs(MimeType.PDF)]
});
}
The code works fine it sends the email to multiple group emails which I want it to send. It has done this for a month now. But until recently, I keep receiving this Mail Delivery Subsystem after 20 minutes or 1 hour from the original email which is sent out and inside the error message email it says:
"The following addresses had permanent fatal errors"
and it points to only one of the emails I send daily mails to. It also says something like this: (reason: 554 5.4.6 Too many hops). and then this:
554 5.4.6 Too many hops 53 (50 max).
The Good Doc's file has Google's time-driven trigger as you can see in the image below. I wonder if somehow the trigger is running twice in the time interval I gave to it. Could it be why this is happening?
In almost all cases 554 5.4.6 Too many hops 53 (50 max) means loop along email delivery path e.g. server A forwards to server B, server B forwards to server A, server A forwards to sever B, …. It is detected by counting Received: headers in message passing via give SMTP/email server.
Suggested fixing procedure:
Inspect Reveived: headers in email bounce message to locate server(s) responsible for the loop.
contact the relevant postmaster
In many years I have seen just one "real life" case when bounce message/email like that was not caused by email delivery loop.

Gmail SMTP error - Temporary block?

I am using Gmail servers to send email from my system, with a program.
Recently I started getting errors like this:
Data command failed: 421 4.7.0 Temporary System Problem. Try again later (WS). 6sm3756432pab.11 - gsmtp
The reasons are given in the support.
Can anybody tell me what is the number of emails that can trigger this issue?
Or is it because of some other reasons?
If you are using your free Gmail account to send bulk emails your are likely to see this kind of responses early on as the service is not intended to send application transaction messages, newsletters etc., event to subscribers that has opted in.
The IMAP/SMTP service provided is for you to be able to use an email client like Microsoft Outlook with your Gmail account.
If you need to send transaction messages, I suggest you google "AWS SES" for starters.
I agree with Anubhav Shrimali that the error occurs if Gmail gets multiple requests simultaneously.
I had solved the problem using Nodemailer in Node.js by adding the 1 second delay between each successive email as follows:
array.foreach(function(data, index) {
setTimeout(() => {
sendmail();
}, 1000 * index);
function sendmail() {
transporter.sendMail(mailOptions, function (error, info) {
if (error) {
console.log(error);
} else {
console.log('Email sent' + info.response);
}
});
}
});
This error occurs if you are using scripts to send emails in quick successions.
An easy way out is to apply a sleep timer in between sending emails.
I applied a timer for 1 second between each successive email.
import time
time.sleep(1) // equivalent to 1 second sleep
I too had the same issue when I tried to send bulk emails using the multi threaded program in Java. Then I heard about Thread Pool Executor. I used it by setting Thread Pool size as 10. After that, this issue has been solved for me.
If this situation is encountered, it should be placed in the retry queue, and the monitoring will be notified if multiple retries fail.
Hope this link can help you:
https://support.google.com/a/answer/3726730
This is probably a result of bulk email sending from the same IP address. As mentioned, use the python sleep function so that there is a bit of a wait between sendings. I find that 1 second is not usually enough time for me, and I sometimes go with a random number of seconds between 1 and 5 for the most optimal results.
import random
import time
time.sleep(random.randint(1, 5))
Don't forget to import the correct modules.
have a rest for 20 minutes , and try again, the error gone

Error send e-mail Amazon AWS

I use Google Service for work, my domain is ".com" I need send mail to ".com.br". The mails of ".com" arrive normal, but the ".com.br" return. I don't know where the mistake is.
In the Route S3 - type MX: Values: below
1 ASPMX.L.GOOGLE.COM
5 ALT1.ASPMX.L.GOOGLE.COM
5 ALT2.ASPMX.L.GOOGLE.COM
10 ALT3.ASPMX.L.GOOGLE.COM
10 ALT4.ASPMX.L.GOOGLE.COM
10 ASPMX3.GOOGLEMAIL.COM
10 ASPMX2.GOOGLEMAIL.COM

Why does this AppleScript get an "AppleEvent handler failed" error on Mac OS X 10.5 Leopard?

First, I know, Leopard is the old-fogey at this point, but it's the minimum I'd like to be able to support with this script, so please bear with me (it's not even possible under Mac OS X 10.4 Tiger due to a bug w/Mail redirect/forward/reply bug I had uncovered long ago).
I've been revisiting building an AppleScript to work in conjunction with Topic Desk's spamtrainer, so it goes through a selection of messages in the Junk folder and attempts to redirect them to a specified mailbox. Here's what I have so far (note that the actual sending is commented out at the moment, more on that later):
(* Train Spam - Redirect (not forward) email from the Junk folder (which hasn't already been redirected or
* determined by the mail server to be spam) to an appropriate spam mailbox on the mail server.
* Developed to be used in conjunction w/spamtrainer on a Mac OS X Server mail server.
*
* v0.1 2011-07-27 - Morgan Aldridge
* Initial version.
*)
using terms from application "Mail"
on perform mail action with messages selectedMsgs in mailboxes selectedMailboxes
tell application "Mail"
-- configuration variables
set junkPrefix to "***JUNK MAIL***"
set junkRecipient to "junkmail#domain.tld"
-- ensure that we're in the Junk mailbox
-- (it'd be disasterous to accidentally redirect mail for training from another mailbox)
if (count of selectedMailboxes) is 1 and (first item of selectedMailboxes) is junk mailbox then
set selCount to (count of selectedMsgs)
set redirectedCount to 0
repeat with counter from 1 to selCount
set msg to item counter of selectedMsgs
-- if the subject doesn't start with junkPrefix and the message hasn't already been redirected, then redirect it
-- (otherwise, if it starts with junkPrefix, it means it was already detected as junk by the mail server)
-- (and, obviously, if it was already redirected, that was probably for the sake of junk training as well)
if subject of msg does not start with junkPrefix and not was redirected of msg then
set newRedirectMsg to redirect msg with opening window
tell newRedirectMsg
-- set the to recipient to that of the specified spam mailbox on the mail server
make new recipient at beginning of to recipients with properties {address:junkRecipient}
-- remove any bcc or cc recipient (we don't want to be spamming anyone else in the process)
delete bcc recipients
delete cc recipients
end tell
-- actually send the message
-- send newRedirectMsg
else
display dialog "Oops, the message was already flagged as junk by the mail server or you've already redirected it!"
end if
end repeat
else
display dialog "Oops, you're not in your Junk mailbox!"
end if
end tell
end perform mail action with messages
end using terms from
-- this is required when _not_ running from the Script menu (e.g. Script Editor, FastScripts, etc.)
using terms from application "Mail"
on run
tell application "Mail" to set sel to selection
tell application "Mail" to set selBox to selected mailboxes of message viewer 1
tell me to perform mail action with messages (sel) in mailboxes (selBox)
end run
end using terms from
When running it from Script Editor.app (so it goes through the on run and tell me to) and a small number of Junk messages select in Mail (this is under Mac OS X 10.5.8 Leopard), it seems to work for the first message (opening a new redirected message, w/to recipient set, and CC/BCC fields emptied), and the other redirected message windows open, but their To/CC/BCC fields are not updated and Script Editor.app pops up the dialog with the "Mail got an error: AppleEvent handler failed" error. The contents of the Event Log are as follows:
tell application "Mail"
get selection
{message id 464214 of mailbox "Junk", message id 464213 of mailbox "Junk", message id 464211 of mailbox "Junk"}
get selected mailboxes of message viewer 1
{junk mailbox}
get junk mailbox
junk mailbox
get subject of message id 464214 of mailbox "Junk"
": Your Invitation Into a Global Directory"
get was redirected of message id 464214 of mailbox "Junk"
false
redirect message id 464214 of mailbox "Junk" with opening window
outgoing message id 400031520
make new recipient at beginning of every to recipient of outgoing message id 400031520 with properties {address:"junkmail#domain.tld"}
to recipient 1 of outgoing message id 400031520
delete every bcc recipient of outgoing message id 400031520
delete every cc recipient of outgoing message id 400031520
get subject of message id 464213 of mailbox "Junk"
"Nominate Your Favorite Products for the Community Choice Awards"
get was redirected of message id 464213 of mailbox "Junk"
false
redirect message id 464213 of mailbox "Junk" with opening window
outgoing message id 378471104
make new recipient at beginning of every to recipient of outgoing message id 378471104 with properties {address:"junkmail#domain.tld"}
"Mail got an error: AppleEvent handler failed."
So, clearly it seems like the failure is with setting the to recipients in all but the first message. Subsequent runs of the script without relaunching Mail result in failures on the first message as well.
The oddest part of this issue is that, when quitting mail after running the script, there's a hidden, blank window for each of the redirected messages (even the one that was successful) that pops up asking if you want to save changes or not. This sounds very similar to something noted in this thread, but I'm not sure what causes it.
So, what's causing this error and failure? How can I resolve it? And, for extra credit, why are the hidden, blank messages created and how can I prevent that from occurring?
Your script looks fine to me.
If I were you, I would try running the script in another OS X account on the same computer, repair permissions, look at your logs (you've already done that, but it's still a good idea), run all relevant software updates, temporarily move your ~/Library/Mail folder to eliminate it as a factor, etc. Tell me what happens, especially if it works again :)