periodic-task

How to call a method / function periodically? (time.sleep fails) [duplicate]

一曲冷凌霜 提交于 2019-12-02 19:53:13
问题 This question already has answers here : How do I create an automatically updating GUI using Tkinter? (4 answers) Closed last year . How can I call update periodically? I tried the following but it skips showing GUI for the limit seconds and then shows only the last update: import tkinter as tk import time root = tk.Tk() widget = tk.Label(root, text="Initial text") widget.pack() def update(): global widget limit = 3 period = 1 for each in range(limit): widget['text'] = each time.sleep(period)

Android Work Manager: How to enqueue Jobs once a month

为君一笑 提交于 2019-12-02 11:36:16
问题 following this question, I looked into Android Job Scheduling and it seems like Work Manager is the latest tool if I want to do something once every month. I built a Worker class and activated it with this snippet in my activity: PeriodicWorkRequest myWorkRequest = new PeriodicWorkRequest.Builder(MonthlyWorker.class, 20, TimeUnit.MINUTES) .build(); WorkManager.getInstance().enqueueUniquePeriodicWork("my fancy test",ExistingPeriodicWorkPolicy.KEEP, myWorkRequest); While i tested the 20 minutes

using asyncio to do periodic task in django

馋奶兔 提交于 2019-12-01 13:05:23
Do you think it is possible to use asyncio to run a task every n seconds in django, so that the main process wouldn't be blocked? Something for example that would print every 5 min in console, like: import asyncio from random import randint async def do_stuff(something, howmany): for i in range(howmany): print('We are doing {}'.format(something)) await asyncio.sleep(randint(0, 5)) if __name__ == '__main__': loop = asyncio.get_event_loop() work = [ asyncio.ensure_future(do_stuff('something', 5)), ] loop.run_until_complete(asyncio.gather(*work)) It seems that django will stop working while the

using asyncio to do periodic task in django

情到浓时终转凉″ 提交于 2019-12-01 10:03:34
问题 Do you think it is possible to use asyncio to run a task every n seconds in django, so that the main process wouldn't be blocked? Something for example that would print every 5 min in console, like: import asyncio from random import randint async def do_stuff(something, howmany): for i in range(howmany): print('We are doing {}'.format(something)) await asyncio.sleep(randint(0, 5)) if __name__ == '__main__': loop = asyncio.get_event_loop() work = [ asyncio.ensure_future(do_stuff('something', 5

WebSocket Server sending messages periodically in python

故事扮演 提交于 2019-12-01 08:07:56
I have a tornado web server in python: import tornado.httpserver import tornado.websocket import tornado.ioloop from tornado.ioloop import IOLoop import tornado.web import time import threading import sys from datetime import datetime from datetime import timedelta def sample(): print 'hiiiii' threading.Timer(10, sample).start() class WSHandler(tornado.websocket.WebSocketHandler): def open(self): print 'new connection' def on_message(self, message): self.write_message(message) self.msg('hellooooooo') print message def msg(self,message): self.write_message(message) threading.Timer(10, self.msg(

How to run a Django celery task every 6am and 6pm daily?

允我心安 提交于 2019-11-30 17:18:33
问题 Hi I have Django Celery in my project. Currently its running every 12hour a day (Midnight/00:00am and 12:00pm). But I want it to run every 6am and 6pm a day. How can I do that? Thanks in advance. Task: from celery.task import periodic_task from celery.schedules import crontab from xxx.views import update_xx_task, execute_yy_task @periodic_task(run_every=crontab(minute=0, hour='*/12'), queue='nonsdepdb3115', options={'queue': 'nonsdepdb3115'}) def xxx_execute_xx_task(): execute_yy_task()

Periodically calling a function in Clojure

本小妞迷上赌 提交于 2019-11-28 23:21:45
I'm looking for a very simple way to call a function periodically in Clojure. JavaScript's setInterval has the kind of API I'd like. If I reimagined it in Clojure, it'd look something like this: (def job (set-interval my-callback 1000)) ; some time later... (clear-interval job) For my purposes I don't mind if this creates a new thread, runs in a thread pool or something else. It's not critical that the timing is exact either. In fact, the period provided (in milliseconds) can just be a delay between the end of one call completing and the commencement of the next. There's also quite a few

Periodically calling a function in Clojure

南楼画角 提交于 2019-11-27 20:56:22
问题 I'm looking for a very simple way to call a function periodically in Clojure. JavaScript's setInterval has the kind of API I'd like. If I reimagined it in Clojure, it'd look something like this: (def job (set-interval my-callback 1000)) ; some time later... (clear-interval job) For my purposes I don't mind if this creates a new thread, runs in a thread pool or something else. It's not critical that the timing is exact either. In fact, the period provided (in milliseconds) can just be a delay

Is there any way to run service continuously in android?

∥☆過路亽.° 提交于 2019-11-27 09:10:36
There are few questions similar to this on StackOverFlow but none of the solutions are working for me Problem The problem is with only few devices like OnePlus and MI ,The service is getting killed as soon as the user swipes away app from recent app. I read that these OEM'S use some aggressive strategies to kill services . I just want to know is there any way to keep service running or start it as soon as it gets killed . What I want I need to run a service which will give location continuously (24/7) in background (This app is only for specific people so no worries about battery life) .

Is there any way to run service continuously in android?

佐手、 提交于 2019-11-26 11:24:52
问题 There are few questions similar to this on StackOverFlow but none of the solutions are working for me Problem The problem is with only few devices like OnePlus and MI ,The service is getting killed as soon as the user swipes away app from recent app. I read that these OEM\'S use some aggressive strategies to kill services . I just want to know is there any way to keep service running or start it as soon as it gets killed . What I want I need to run a service which will give location