Closed jjok closed 5 years ago
Hmm... That doesn't seem to fix it. Not sure what to do... Has anyone else seen this issue? Is it just because I'm running in Docker? It happens when I call the endpoint, then stop and start the container, the hit the endpoint again.
I haven't installed the Docker version, will do so tonight and check it out. I would have also expected the GPIO.cleanup()
to do the trick.
And you haven't seen that warning when running straight on, presumably, Raspbian?
I do not see the warning in the json response. I do see it after calling the endpoint and then calling the pin from the terminal. I added the cleanup call to each section of the loop and it went away on subsequent calls:
`if (repeatValue > 1):
for _ in itertools.repeat(None, repeatValue):
GPIO.output(int(pinNumber), GPIO.LOW)
time.sleep(timeOn)
GPIO.output(int(pinNumber), GPIO.HIGH)
time.sleep(repeatDelay)
GPIO.cleanup()
else:
GPIO.output(int(pinNumber), GPIO.LOW)
time.sleep(timeOn)
GPIO.output(int(pinNumber), GPIO.HIGH)
GPIO.cleanup()`
Where did you add the GPIO.cleanup()
?
Hmm... I added it at the end. Right before the function returns.
if (repeatValue > 1):
for _ in itertools.repeat(None, repeatValue):
GPIO.output(int(pinNumber), GPIO.LOW)
time.sleep(timeOn)
GPIO.output(int(pinNumber), GPIO.HIGH)
time.sleep(repeatDelay)
else:
GPIO.output(int(pinNumber), GPIO.LOW)
time.sleep(timeOn)
GPIO.output(int(pinNumber), GPIO.HIGH)
GPIO.cleanup()
Just tested it your way and there was no warning. Probably something with the Docker build but I don't know enough to say...
Im running:
Description: Raspbian GNU/Linux 9.6 (stretch) Release: 9.6 Codename: stretch
I wonder it was whitespace-related? I was using vi
and having trouble wrangling the tabs.
Maybe, but Python is pretty good about breaking and erroring out on any tab issues. I'll install Docker and see what happens.
Having some issues with the Docker set up, doesn't appear to be using the mysql config. I know you mentioned something about that earlier. Will resolve but will be later tonight or tomo.
Did you run the commands in the same order as the README? The whole codebase (./
) gets copied into the image at build time, so you have to have edited the config file before then.
Oh. Hang on. That's my problem, isn't it? :man_facepalming: That's why I wasn't seeing the change having any effect.
Ahhhhhh! That makes sense! Do I have to do anything special to rebuild? Like remove it first? Or does Docker know to just overwrite?
Nope. Just run the build
command again. It should have cached all the steps that haven't changed since the last build, so it should just add the files again and do the last few bits, rather than installing everything as it did the first time. It should take seconds, rather than tens of minutes.
Surprisingly, my original fix works when I actually test it properly. I'll open a PR in a sec.
Sweet, thanks!
I get this message when calling
/relayControl
.I think it's just a case of adding
GPIO.cleanup()
at the end of the function, so it's cleaned up for the next run.