Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
  • Apr 08 15:08
    agronholm commented #384
  • Apr 08 12:39
    couling commented #384
  • Apr 08 12:36
    couling commented #384
  • Apr 06 23:11
    agronholm commented #421
  • Apr 06 23:03
    TAUMachado commented #421
  • Apr 06 22:52
    agronholm commented #421
  • Apr 06 22:48
    TAUMachado commented #421
  • Apr 06 13:01
    abood91 opened #505
  • Apr 05 20:12
    6peterlu closed #504
  • Apr 05 20:12
    6peterlu commented #504
  • Apr 05 18:37
    agronholm commented #504
  • Apr 05 14:48
    6peterlu commented #504
  • Apr 05 14:44
    agronholm commented #504
  • Apr 05 14:41
    6peterlu opened #504
  • Apr 03 16:32
    agronholm commented #421
  • Apr 03 13:02
    TAUMachado commented #421
  • Apr 03 13:02
    TAUMachado commented #421
  • Apr 03 12:42
    TAUMachado commented #421
  • Apr 03 11:32
    agronholm commented #421
  • Apr 03 10:58
    agronholm commented #421
Suhrob Malikov
@malikovss
@agronholm thanks
Alex Grönholm
@agronholm
@malikovss to improve the documentation, could I ask why you were unable to find this on your own? where did you look?
Alex Grönholm
@agronholm
yes, and the relevant API documentation can be accessed by clicking on add_job()
did you expect there to be examples for every possible parameter of that method?
Mirkenan Kazımzade
@Kenan7

so İ have a Bot class which is from twitchio package, and that's running asynchronously.

what would I have to do if I wanted to make apshceduler and twitchio bot run together?

aim: I will update the data periodically so my bot will respond faster

from twitchio.ext import commands

class Bot(commands.Bot):
    def __init__(self):
        ...

bot = Bot()
bot.run() # there is run_until_complete function in run()
Alex Grönholm
@agronholm
@Kenan7 which async framework is twitchio using?
Mirkenan Kazımzade
@Kenan7
looks like just asyncio
Alex Grönholm
@agronholm
how do you know?
ok, the source looks like it uses asyncio
Mirkenan Kazımzade
@Kenan7
yes :)
Alex Grönholm
@agronholm
start the scheduler first, then the bot
Alex Grönholm
@agronholm
@Kenan7 yeah, and use AsyncIOScheduler
Mirkenan Kazımzade
@Kenan7
I tried this but I get this error: maxiumum number of running instances reached(1) but I set max_instances to 5
try:
    sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    sock.bind(("127.0.0.1", 47200))
    log.info("socket bind")
except socket.error:
    log.info("socket error")
    pass
else:
    log.info("socket - register extensions")
    scheduler = AsyncIOScheduler()
    log.basicConfig()
    log.getLogger("apscheduler").setLevel(log.DEBUG)
    scheduler.start()
    scheduler.add_job(
        test_function,
        trigger="interval",
        id="test_job",
        replace_existing=True,
        seconds=30,
    )


bot = Bot()
bot.run()
@agronholm
Mirkenan Kazımzade
@Kenan7
I handled them with threads
Alex Grönholm
@agronholm
@Kenan7 where did you set the maximum number of instances?
give me something that lets me see the problem
shahrooz
@shahrooz1397
hello guys
i need to remove and put a value from database at two different time
for example i want to put str(hello) at 8 am and remove it at 10pm
i am noob at apscheduler what should i do
which one of these are suitble for my job: date, cron interval?
Alex Grönholm
@agronholm
@shahrooz1397 you need to do these every day?
shahrooz
@shahrooz1397
@shahrooz1397 you need to do these every day?
yes i do
Alex Grönholm
@agronholm
ok, so cron is your best bet
shahrooz
@shahrooz1397
thanks do you have any example
Alex Grönholm
@agronholm
hour=8 for the first job (put), hour=22 for the second job (remove)
the API documentation for CronTrigger has examples
shahrooz
@shahrooz1397
@agronholm thank you very much
Omer Katz
@thedrow
@agronholm How is it going with 4.0?
Alex Grönholm
@agronholm
I've struggled a lot with the sync/async scheduler and worker interfaces, but I think I've made a breakthrough now
Omer Katz
@thedrow
Is it usable from master?
I'm working on it now
Alex Grönholm
@agronholm
no, not yet
Omer Katz
@thedrow
I just need the async scheduler
Alex Grönholm
@agronholm
I expect to push a commit this week with appropriate changes
you don't want it in the state it's in now on my laptop
Omer Katz
@thedrow
Do you accept interval=0?
Alex Grönholm
@agronholm
no?
why
Omer Katz
@thedrow
Because I was wondering if I can run something in a loop using APScheduler.
Omer Katz
@thedrow
Maybe there could be a LoopInterval which just calls the task after it is done again
Alex Grönholm
@agronholm
@thedrow what is the point of using a scheduler for that?
Omer Katz
@thedrow
I have periodic tasks and continious tasks.
I'd like to use the same code path
Alex Grönholm
@agronholm
you could just add a job without a schedule (you can do that with apscheduler 4.0)
and in the code, make a while True: loop
interval=0 doesn't make sense because it would spawn an endless number of jobs, choking your machine
Omer Katz
@thedrow
so just scheduler.add_job?
Alex Grönholm
@agronholm
I think I made it so you can just omit the trigger if you want to queue a one-off task
(in v4.0)
sdementen
@sdementen
Hello @agronholm , i just discovered http://www.grantjenks.com/docs/diskcache/ that is a persistent cache on disk that is multi-thread and multi-process safe and can be used for IPC. Maybe useful for your project...