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

Service.start should take a callback #58

Open
Jaymon opened this issue Jan 15, 2020 · 0 comments
Open

Service.start should take a callback #58

Jaymon opened this issue Jan 15, 2020 · 0 comments

Comments

@Jaymon
Copy link
Owner

Jaymon commented Jan 15, 2020

Currently, in some code I do something like this:

Upstart("SERVICE_NAME", False).start()

logger.debug("SERVICE is starting")

c = Client()
for x in range(10):
    r = c.get("/some/url")
    if r.code == 204:
        break
    else:
        logger.debug("SERVICE has not started")
        time.sleep(0.25)

logger.debug("SERVICE is ready")

It would be great if I could put just the meat into a callback and then the actual .start method will handle the looping and checking the return value of the callback.

This should be implemented in one of two ways, .start should take a check callback, and the service should have a .check method that returns True, so subclasses could override the .check method, or if they pass it in then it will be set to self.check.

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

1 participant