Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

the function executed twice after every time interval #18

Open
maanas-pm opened this issue May 8, 2020 · 3 comments
Open

the function executed twice after every time interval #18

maanas-pm opened this issue May 8, 2020 · 3 comments

Comments

@maanas-pm
Copy link

tl.start(block=Fasle)

the functions are exec ute twice when the block is false.

from timeloop import Timeloop
from datetime import timedelta, datetime
from flask import Flask, request
from flask_restful import Api

app = Flask(name)
api = Api(app)
tl = Timeloop()

@tl.job(interval=timedelta(seconds=5))
def gatherAFXReport():
try:
print("inside {}".format(datetime.now().strftime('%s')))
except Exception as e:
print(str(e))

if name == 'main':
tl.start(block=False)
app.run(debug=True, host='0.0.0.0')

output

[2020-05-08 14:45:49,248] [timeloop] [INFO] Starting Timeloop..
[2020-05-08 14:45:49,248] [timeloop] [INFO] Registered job <function gatherAFXReport at 0x107d977d0>
[2020-05-08 14:45:49,248] [timeloop] [INFO] Timeloop now started. Jobs will run based on the interval set

  • Serving Flask app "test" (lazy loading)
  • Environment: production
    WARNING: This is a development server. Do not use it in a production deployment.
    Use a production WSGI server instead.
  • Debug mode: on
  • Running on http://0.0.0.0:5000/ (Press CTRL+C to quit)
  • Restarting with stat
    [2020-05-08 14:45:49,500] [timeloop] [INFO] Starting Timeloop..
    [2020-05-08 14:45:49,501] [timeloop] [INFO] Registered job <function gatherAFXReport at 0x1075e77d0>
    [2020-05-08 14:45:49,501] [timeloop] [INFO] Timeloop now started. Jobs will run based on the interval set
  • Debugger is active!
  • Debugger PIN: 100-118-572
    inside 1588929354
    inside 1588929354
    inside 1588929359
    inside 1588929359
    inside 1588929364
    inside 1588929364
    inside 1588929369
    inside 1588929369
    inside 1588929374
    inside 1588929374
@lockieRichter
Copy link

I don't think things are being executed twice, I think this is an issue with the logging in the module. See #5.

I'm having a similar problem using this with Flask as well.

@projx
Copy link

projx commented Feb 14, 2021

I don't think things are being executed twice, I think this is an issue with the logging in the module. See #5.

I'm having a similar problem using this with Flask as well.

I've experienced similar issues with python Logging and Flask..

@coolkau
Copy link

coolkau commented Nov 7, 2022

This is a bug in the timeloop project. A logging handler is set but never removed. This can be fixed by adding

for h in self.logger.handlers: self.logger.removeHandler(h)

to the stop method

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants