9
내가 본 모든 장소와 같이 열린 핸들러가 아닌이 uniq id로 Gearman 작업의 상태를 가져와야합니다.유니어 ID로 기어 만 작업의 상태를 얻는 방법은 무엇입니까?
가능합니까? python-gearman v. 2에서 사용 ...
도움 주셔서 감사합니다!
내가 본 모든 장소와 같이 열린 핸들러가 아닌이 uniq id로 Gearman 작업의 상태를 가져와야합니다.유니어 ID로 기어 만 작업의 상태를 얻는 방법은 무엇입니까?
가능합니까? python-gearman v. 2에서 사용 ...
도움 주셔서 감사합니다!
python-gearman-API에서 친숙한 방식으로 노출되지 않았으므로이 문제를 해결하기 위해 상당한 노력을해야했습니다. 그러나 직접 GearmanJob
및 GearmanJobRequest
의 적절한 인스턴스를 만들어 해결할 수 있습니다. 여기
import gearman
client = gearman.GearmanClient(['localhost'])
result = client.submit_job('reverse', 'this is a string', background=True);
하고, 작업의 핸들. 연결 정보는 result.job.connection
(.gearman_host
및 .gearman_port
)을 통해 사용할 수 있으며 핸들은 result.job.handle
을 통해 사용할 수 있습니다.
당신이 GearmanClient
만들 현재 실행중인 작업의 상태를 확인할 수 있지만 현재 상태를 조회 할 서버 공급하려면
client = gearman.GearmanClient(['localhost'])
# configure the job to request status for - the last four is not needed for Status requests.
j = gearman.job.GearmanJob(client.connection_list[0], result.job.handle, None, None, None, None)
# create a job request
jr = gearman.job.GearmanJobRequest(j)
jr.state = 'CREATED'
# request the state from gearmand
res = client.get_job_status(jr)
# the res structure should now be filled with the status information about the task
print(str(res.status.numerator) + "/" + str(res.status.denominator))
희망이 도움이!
또한 github의 python-gearman 포크에 편리한 메소드를 추가했습니다. 언제든지 공식 배포판에 포함될 것이라고 생각하지 않지만 패치는 다음 사이트에서 구할 수 있습니다. https://github.com/matslindh/python-gearman/commit/983e97c5055f1ccf7059f00215cc6e026ebc1ba0 – MatsLindh
감사합니다. 그것은 내가 필요로하는 것처럼 보입니다.하지만 작업을위한 상태와 추가 데이터를 저장하기 위해 memcache 래퍼를 사용하여 문제를 해결했습니다. –