I'd like to schedule a task to run at various times in the future. I'm trying to use the eta option when calling the task to do this. This part works fine on its own, but at the same time, I'd like to have a rate limit on the task. I'm not able to do both: schedule the task to run in the future, but also get celery to respect the rate limit.
Here is an example (rate_limit_eta.py)
from celery import Celery
from datetime import datetime, timedelta
app = Celery('rate_limit_eta', broker='amqp://guest#localhost//')
#app.task(rate_limit='4/m')
def my_task():
print 'execution timestamp: {}'.format(datetime.utcnow())
if __name__ == '__main__':
now = datetime.utcnow()
d = now + timedelta(seconds=5)
print now
for i in range(10):
my_task.apply_async(eta=d)
In the loop, when I call 'my_task' with eta=d, the tasks get executed as fast as possible. The rate_limit is not respected.
my_task.apply_async(eta=d)
[2015-06-12 13:45:15,750: WARNING/Worker-1] execution timestamp: 2015-06-12 13:45:15.748498
[2015-06-12 13:45:15,757: WARNING/Worker-1] execution timestamp: 2015-06-12 13:45:15.757757
[2015-06-12 13:45:15,760: WARNING/Worker-1] execution timestamp: 2015-06-12 13:45:15.759992
[2015-06-12 13:45:15,763: WARNING/Worker-1] execution timestamp: 2015-06-12 13:45:15.763614
[2015-06-12 13:45:15,766: WARNING/Worker-1] execution timestamp: 2015-06-12 13:45:15.765996
[2015-06-12 13:45:15,768: WARNING/Worker-1] execution timestamp: 2015-06-12 13:45:15.768424
[2015-06-12 13:45:15,771: WARNING/Worker-1] execution timestamp: 2015-06-12 13:45:15.771079
[2015-06-12 13:45:15,774: WARNING/Worker-1] execution timestamp: 2015-06-12 13:45:15.774561
[2015-06-12 13:45:15,777: WARNING/Worker-1] execution timestamp: 2015-06-12 13:45:15.777425
[2015-06-12 13:45:15,780: WARNING/Worker-1] execution timestamp: 2015-06-12 13:45:15.780207
But if I do not schedule the task (i.e. without the eta), then the rate limit is enforced.
my_task.apply_async()
[2015-06-12 13:47:05,844: WARNING/Worker-1] execution timestamp: 2015-06-12 13:47:05.843872
[2015-06-12 13:47:05,850: WARNING/Worker-1] execution timestamp: 2015-06-12 13:47:05.850502
[2015-06-12 13:47:21,919: WARNING/Worker-1] execution timestamp: 2015-06-12 13:47:21.919120
[2015-06-12 13:47:35,937: WARNING/Worker-1] execution timestamp: 2015-06-12 13:47:35.937060
[2015-06-12 13:47:51,959: WARNING/Worker-1] execution timestamp: 2015-06-12 13:47:51.959174
[2015-06-12 13:48:05,976: WARNING/Worker-1] execution timestamp: 2015-06-12 13:48:05.976197
[2015-06-12 13:48:21,998: WARNING/Worker-1] execution timestamp: 2015-06-12 13:48:21.998254
[2015-06-12 13:48:36,014: WARNING/Worker-1] execution timestamp: 2015-06-12 13:48:36.014837
[2015-06-12 13:48:52,041: WARNING/Worker-1] execution timestamp: 2015-06-12 13:48:52.041326
[2015-06-12 13:49:06,057: WARNING/Worker-1] execution timestamp: 2015-06-12 13:49:06.057286
Am I doing something wrong?
I had the same issue, and I found why. I had a look into Celery code and this behaviour is coming from the strategy code, which does something along the lines of:
if req.eta:
apply_eta()
else:
check_if_rate_limited()
I'm afraid it's something to do that ETAs and rate limit being 2 incompatible ways to tell Celery when the task should be executed. Celery has to choose one over the other, and it happens to be ETA.
My link is to v3 of Celery (as I suspect this question was asked for v3), but at time of writing, this is still valid on Celery's master branch. I guess this limitation could be documented a bit better somewhere (here?), it's just a pull request away!
UPDATE:
I've opened an issue on the Celery project.
Related
I am facing below error while building kernel from local workspace(created by devtool modify virtual/kernel). If I do not have workspace created then I don't see any error.
ERROR: ExpansionError during parsing /home/aws-fsp-build/rax-workspace/yocto/meta-ti/recipes-kernel/linux/linux-ti-staging-rt_5.10.bb
Traceback (most recent call last):
File "Var <KERNEL_LOCALVERSION>", line 1, in <module>
bb.data_smart.ExpansionError: Failure expanding variable KERNEL_LOCALVERSION, expression was -g${#d.getVar('SRCPV', True).split('+')[1]} which triggered exception IndexError: list index out of range
Can you help me on resolving this? I need to have workspace since I am working on kernel related changes. I am using dunfell branch of meta-ti.
Loading cache: 100% |#########################################################################################################| Time: 0:00:00
Loaded 4480 entries from dependency cache.
WARNING: /home/aws-fsp-build/rax-workspace/yocto/meta-ti/recipes-kernel/linux/linux-ti-staging-rt_5.10.bb: Exception during build_dependencies for do_configure
WARNING: /home/aws-fsp-build/rax-workspace/yocto/meta-ti/recipes-kernel/linux/linux-ti-staging-rt_5.10.bb: Error during finalise of /home/aws-fsp-build/rax-workspace/yocto/meta-ti/recipes-kernel/linux/linux-ti-staging-rt_5.10.bb
ERROR: ExpansionError during parsing /home/aws-fsp-build/rax-workspace/yocto/meta-ti/recipes-kernel/linux/linux-ti-staging-rt_5.10.bb
Traceback (most recent call last):
File "Var <KERNEL_LOCALVERSION>", line 1, in <module>
bb.data_smart.ExpansionError: Failure expanding variable KERNEL_LOCALVERSION, expression was -g${#d.getVar('SRCPV', True).split('+')[1]} which triggered exception IndexError: list index out of range
WARNING: /home/aws-fsp-build/rax-workspace/yocto/meta-ti/recipes-kernel/linux/linux-ti-staging-rt_5.4.bb: Cooker received SIGTERM, shutting down...
WARNING: /home/aws-fsp-build/rax-workspace/yocto/meta-carrier/recipes-kernel/linux/linux-ti-staging_4.19.bb: Cooker received SIGTERM, shutting down...
WARNING: /home/aws-fsp-build/rax-workspace/yocto/meta-carrier/recipes-kernel/mstp-mod/mstp-mod.bb: Cooker received SIGTERM, shutting down...
Summary: There were 5 WARNING messages shown.
Summary: There was 1 ERROR message shown, returning a non-zero exit code.
It seems like after moving to the workspace, the SRCPV variable changes formatting, which leads to parsing failure. Try to add something like this to the build/workspace/appends/linux-ti-staging-rt_5.4.bbappend file:
KERNEL_LOCALVERSION = "-g999"
I'm using boofuzz 0.1.6 on an Ubuntu machine. I'm trying to get the process_monitor_unix to connect to the server programm I want to fuzz. When I start procmon and my script, I get the following output on procmon:
[05:47.20] Process Monitor PED-RPC server initialized:
[05:47.20] listening on: 0.0.0.0:26002
[05:47.20] crash file: /home/rico/PycharmProjects/iec104_server_fuzz/boofuzz-crash-bin
[05:47.20] # records: 0
[05:47.20] proc name: None
[05:47.20] log level: 1
[05:47.20] awaiting requests...
[05:47.24] updating target process name to './simple_server'
[05:47.24] updating stop commands to: [u'kill -SIGINT $(pidof simple_server)']
[05:47.24] updating start commands to: [u'/home/rico/iec60870/lib60870-master/lib60870-C/examples/cs104_server/simple_server']
[05:47.24] updating crash bin filename to 'boofuzz-crash-bin-2020-03-19T16-47-24'
[05:47.24] Starting target...
[05:47.24] starting target process
[05:47.24] done. waiting for start command to terminate.
APCI parameters:
t0: 10
t1: 15
t2: 10
t3: 20
k: 12
w: 8
The output "APCI parameters ..." is a message of the server which is send everytime the server is started. Therefore I think it's up and running. My problem is that it isn't responding to incoming tcp-packages.
The output of my fuzzscript is the following:
[2020-03-19 17:47:24,314] Info: Web interface can be found at http://localhost:26000
[2020-03-19 17:47:24,316] Test Case: 1: activate->s_formatAPDU.no-name.1
[2020-03-19 17:47:24,316] Info: Type: Bytes. Default value: b'\x91\xef\xa5'. Case 1 of 270 overall.
[2020-03-19 17:47:24,316] Test Step: Calling procmon pre_send()
It get's stuck in this test step.
When I start the server first, then procmon, then the fuzzscript, I get the following error:
[10:29.51] Process Monitor PED-RPC server initialized:
[10:29.51] listening on: 0.0.0.0:26002
[10:29.51] crash file: /home/rico/PycharmProjects/iec104_server_fuzz/boofuzz-crash-bin
[10:29.51] # records: 0
[10:29.51] proc name: None
[10:29.51] log level: 1
[10:29.51] awaiting requests...
[10:29.55] updating target process name to './simple_server'
[10:29.55] updating stop commands to: [u'kill -SIGINT $(pidof simple_server)']
[10:29.55] updating start commands to: [u'/home/rico/iec60870/lib60870-master/lib60870-C/examples/cs104_server/simple_server']
[10:29.55] updating crash bin filename to 'boofuzz-crash-bin-2020-03-19T21-29-55'
[10:29.55] Starting target...
[10:29.55] starting target process
[10:29.55] done. waiting for start command to terminate.
APCI parameters:
t0: 10
t1: 15
t2: 10
t3: 20
k: 12
w: 8
Starting server failed!
[10:29.56] searching for process by name "./simple_server"
Exception in thread Thread-1:
Traceback (most recent call last):
File "/usr/lib/python2.7/threading.py", line 801, in __bootstrap_inner
self.run()
File "/home/rico/.local/lib/python2.7/site-packages/boofuzz/utils/debugger_thread_simple.py", line 130, in run
self.spawn_target()
File "/home/rico/.local/lib/python2.7/site-packages/boofuzz/utils/debugger_thread_simple.py", line 115, in spawn_target
self.watch()
File "/home/rico/.local/lib/python2.7/site-packages/boofuzz/utils/debugger_thread_simple.py", line 166, in watch
for (pid, name) in _enumerate_processes():
File "/home/rico/.local/lib/python2.7/site-packages/boofuzz/utils/debugger_thread_simple.py", line 36, in _enumerate_processes
yield (pid, psutil.Process(pid).name())
File "/home/rico/.local/lib/python2.7/site-packages/psutil/__init__.py", line 346, in __init__
self._init(pid)
File "/home/rico/.local/lib/python2.7/site-packages/psutil/__init__.py", line 386, in _init
raise NoSuchProcess(pid, None, msg)
NoSuchProcess: psutil.NoSuchProcess no process found with pid 21574
Now this seems strange to me, because the pid 21574 isn't the pid of the running server-process. Does someone now more about this? Even wild guesses are appreciated!
If you need other infos aswell, I will gladly provide them.
I fixed the error by deleting the line
"proc_name": '/home/rico/iec60870/lib60870-master/lib60870-C/examples/cs104_server/simple_server' in my fuzzscript. I also had to make sure that the server is !not! already running when I start my fuzzscript.
Now, the server starts in the terminal which runs procmon.
I don't know if there is a better way to fix this, but atleast the procmon can do it's job now.
I'm trying to run a peak calling tool within a conda environment using snakemake.
The script looks as such (I only added the rows connect to the problem):
rule all:
input:
expand('{project}/{organism}/{mapper}/seacr/{pattern}.auc.threshold.bed', pattern = PATTERN, sample = IDS, organism = config['org'], project = config['project'], mapper = config['mapper']) # SEACR - run the peak calling
rule seacr_run:
input:
IP = '{project}/{organism}/{mapper}/seacr/IP_{PATTERN}.bedgraph',
IgG = '{project}/{organism}/{mapper}/seacr/IgG_{PATTERN}.bedgraph',
output:
bed1 = '{project}/{organism}/{mapper}/seacr/{PATTERN}.auc.threshold.bed',
shell:
'''
bash /fs/home/yeroslaviz/SEACR/SEACR_1.3.sh {input.IP} 0.01 non stringent {output.bed1}
'''
When running the -nps dryrun of the snamemake command I get the correct command printed to STDOUT
> snakemake -nps /fs/pool/pool-bcfngs/scripts/P193.ChipSeq.Snakemake -j 100
...
Building DAG of jobs...
Job counts:
count jobs
1 all
1 seacr_run
2
[Tue Mar 3 13:56:19 2020]
rule seacr_run:
input: P193/Mmu.GrCm38/bowtie2/seacr/IP_H3K4m3.bedgraph, P193/Mmu.GrCm38/bowtie2/seacr/IgG_H3K4m3.bedgraph
output: P193/Mmu.GrCm38/bowtie2/seacr/H3K4m3.auc.threshold.bed
jobid: 22
wildcards: project=P193, organism=Mmu.GrCm38, mapper=bowtie2, PATTERN=H3K4m3
bash /fs/home/yeroslaviz/SEACR/SEACR_1.3.sh P193/Mmu.GrCm38/bowtie2/seacr/IP_H3K4m3.bedgraph 0.01 non stringent P193/Mmu.GrCm38/bowtie2/seacr/H3K4m3.auc.threshold.bed
[Tue Mar 3 13:56:19 2020]
localrule all:
...
Job counts:
count jobs
1 all
1 seacr_run
2
This was a dry-run (flag -n). The order of jobs does not reflect the order of execution.
When running the command above in the command line the tool works without problems. But hwhen I try to run it within the snakemake workflow I get the following error:
Waiting at most 5 seconds for missing files.
MissingOutputException in line 67 of /fs/pool/pool-bcfngs/scripts/P193.ChipSeq.Snakemake:
Missing files after 5 seconds:
P193/Mmu.GrCm38/bowtie2/seacr/H3K4m3.auc.threshold.bed
This might be due to filesystem latency. If that is the case, consider to increase the wait time with --latency-wait.
Shutting down, this might take some time.
Exiting because a job execution failed. Look above for error message
Can anyone explain what is happening?
Thanks
So I'm basically attempting to write some simple code using promises and I'm having a bit of trouble understanding why this particular code works every other time.
Promise = require('bluebird')
mkdirp = Promise.promisify(require('mkdirp'))
rm = Promise.promisify(require('rimraf'))
console.log "Preparing build directory"
rm('build')
.then(mkdirp('build'))
This will complete successfully the first run, but the second will fail, and so on.
Here is the steps:
┌[adam#bigboi] [/dev/pts/5] [master ⚡]
└[~/Projects/bummyjab]> time coffee index.coffee ~/Dropbox/Articles/*.md
Preparing build directory
coffee index.coffee ~/Dropbox/Articles/*.md 0.25s user 0.02s system 100% cpu 0.267 total
┌[adam#bigboi] [/dev/pts/5] [master ⚡]
└[~/Projects/bummyjab]> stat build
File: ‘build’
Size: 4096 Blocks: 8 IO Block: 4096 directory
Device: 804h/2052d Inode: 17172395 Links: 2
Access: (0775/drwxrwxr-x) Uid: ( 1000/ adam) Gid: ( 1000/ adam)
Access: 2015-06-25 22:07:49.061331341 -0400
Modify: 2015-06-25 22:07:49.061331341 -0400
Change: 2015-06-25 22:07:49.061331341 -0400
Birth: -
┌[adam#bigboi] [/dev/pts/5] [master ⚡]
└[~/Projects/bummyjab]> time coffee index.coffee ~/Dropbox/Articles/*.md
Preparing build directory
Unhandled rejection Error: EEXIST: file already exists, mkdir '/home/adam/Projects/bummyjab/build'
at Error (native)
coffee index.coffee ~/Dropbox/Articles/*.md 0.20s user 0.03s system 100% cpu 0.235 total
Unfortunately, my google skills for this haven't come up with a reason why this is happening.
Thanks
If you're trying to control the order so that mkdirp('build') happens only after rm('build') has completed, then you need to pass a function reference to .then() like this:
rm('build').then(function () {
return mkdirp('build');
});
Or, you could use .bind():
rm('build').then(mkdirp.bind(null, 'build'));
What you were doing is executing mkdirp() immediately and passing that return value to .then() which doesn't wait to execute it until the promise is resolved.
I wan't to change the repeat time from one task from 5 minutes to 1 minute. The task is there:
Folder: \
HostName: ZSERVER
TaskName: \Check_IIS_Server
Next Run Time: 04.10.2012 16:30:45
Status: Ready
Logon Mode: Interactive/Background
Last Run Time: 04.10.2012 16:25:45
Last Result: 0
Author: WACKER\createuser
Task To Run: powershell.exe powershell.exe -Noninteract
ive -Command "&{C:\Logfiles_Poly\Check_IIS_Server.ps1}"
Start In: N/A
Comment: N/A
Scheduled Task State: Enabled
Idle Time: Disabled
Power Management: Stop On Battery Mode, No Start On Batteries
Run As User: WACKER\Adminuser
Delete Task If Not Rescheduled: Enabled
Stop Task If Runs X Hours and X Mins: 01:00:00
Schedule: Scheduling data is not available in this format.
Schedule Type: Daily
Start Time: N/A
Start Date: N/A
End Date: N/A
Days: Every 1 day(s)
Months: N/A
Repeat: Every: 0 Hour(s), 5 Minute(s)
Repeat: Until: Time: None
Repeat: Until: Duration: 24 Hour(s), 0 Minute(s)
Repeat: Stop If Still Running: Disabled
Now my change command is, i wan't to edit the repeat time to one minute:
C:\Users\username>schtasks /change /tn "Check_IIS_Server_Poly" /ri 1
ERROR: The parameter is incorrect.
Why did I can't edit this job over command?
Thanks,
Horst
You need to provide full path to the task, in your case it'll be \Check_IIS_Server. I don't see anything else that could be wrong here.
I create a task (schtasks /change /mo 1 /tn "Test") with repeat time one minute and edit the other settings manuell.
Horst