Yelp / python-gearman

Gearman API - Client, worker, and admin client interfaces
http://github.com/Yelp/python-gearman/
Other
242 stars 122 forks source link

Add method for retrieving status of a running task #15

Open matslindh opened 13 years ago

matslindh commented 13 years ago

Added convenience function for retrieving the status of a task by just submitting the task handle.

To be able to query the correct server for the status, this requires the client to only have one added server.

Feel free to clean up the patch (I'm not happy about having to set CREATED as status, etc. It works, but there's probably better ways of achieving this).

eskil commented 12 years ago

I think requiring servers to have unique names is reasonable. More reasonable that limiting this to 1 connection. If you rewrite it to poll all servers and rely on them having unique hostnames, I'm ok with that just documenting that little detail. Another option is to take the connection as a argument, and poll all if it's None, and if not, poll just that 1 connection.

Also, instead of directly instantiating GearmanJobRequest, please use self.job_request_class. That will be useful for those of us who mock all that stuff for unit-testing.

(Incidentally, the hostname is in the handle, but that won't necessarily match the client side hostname, so that can't be used.)