python - Celery beat task stops fails after a few beats (opencv) -
i have celery task runs on beat every 60 seconds grab webcam, take still it, , write file server can serve on webpage later. image taking uses opencv via cv2 library in python.
it looks this:
@app.task # task , save webcam image def getwebcamimage() logger.debug("capturing image attempt") c = cv2.videocapture(0) #returns videocapture object flag, frame = c.read() #grabs , decodes next frame cv2.imwrite('file/loc/img.jpg, frame) #writes frame file logger.debug('saved image...hopefully') c.release() #releases videocapture object return 0
everything goes great first few minutes, spits out normal errors not being able webcam properties , stops. , never starts again!
...debug/beat] celerytest.getwebcamimage[process]:capturing image attempt vidoc_querymenu:invalid argument vidoc_querymenu:invalid argument vidoc_querymenu:invalid argument
this how looks when work, keeps going. idea stopping it? running on rasperry pi 240mb dedicated arm core , 16 graphics.
things have done try fix it:
$sudo sysctl vm.overvommit_memory=1
so doesent throw mem. allocation errors $sudo rmmod ucvideo $sudo modprobe ucvideo nodrop=1 timeout=5000 quirks=0x80 driver more patient cam. have tried few cams, not issue.
please whatever suggestions or tests think of. tricky 1 because is: on pi, , pi/cellery cross. going try running script guvcview, feel py/opencv option cleaner because easier install, , either way know why doesn't work!
news:
dmesg reveals celery process being killed because out of memory. way fix this? how, if @ all, objects created in tasks destroyed?
this turned out unrelated celery, , related cv.
if every time cv2.videocapture object released, not deleted, memory still reserved. on pi, has little memory, took memory , killed. investigated memory usage top command in linux.
it happens on larger computers, symptoms more severe on pi.
Comments
Post a Comment