-
Notifications
You must be signed in to change notification settings - Fork 1
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
ZigBee object persistence across multiple HTTP request #36
Comments
IRC #python (12/06/14 ~ 8:00pm EST):
|
We may implement a python global dictionary, and store the object within it. This will allow us to avoid the use of a database, and later clearing the database cached values upon system reboot. IRC #python (12/07/14 ~ 4:30pm EST):
|
No such thing as "object persistence". Objects exist inside a process and can't live longer than the process does. |
I've determined that an http request that invokes the Zigbee object, creates a new process (pid), called def start(self):
self.xbee = ZigBee(self.ser,callback=self.message_received,escaped=True) Therefore, the new process, is most likely associated with Zigbee instance, and lives indefinitely, until the machine is rebooted. Note: i used the command |
If the python method which originally contained the one line invoking the def start(self):
self.xbee = ZigBee(self.ser,callback=self.message_received,escaped=True) is replaced with dummy code: def start(self):
print 'hello, there' no new process is created, when an http request (via web-interface / ajax) is made to the replaced method. The replaced dummy code method has a similar result as the following: def start(self):
self.xbee = ZigBee(self.ser,callback=self.message_received,escaped=True)
self.xbee.halt()
self.ser.close() No, new process is created - since, any threads related the Note: i used the command |
If we change the original method responsible for invoking the def start(self):
self.xbee = ZigBee(self.ser,callback=self.message_received,escaped=True) to the following: def start(self):
self.xbee = ZigBee(self.ser,callback=self.message_received,escaped=True)
import os
print os.getpid()
self.xbee.halt()
self.ser.close() we get the process id, or
|
IRC #arduino (12/09/14 ~ 12:15pm EST):
|
@washort I've been a little shy about going the route of Flask. I've attempted to study it within my Machine Learning repository couple months ago. Being a little overwhelmed, I decided to use HTTP (post) requests, AJAX, and JSON to php. |
Generally, only one connection can be made on a given serial port. Therefore, we will need to create a persistent state for a chosen python script responsible for creating the ZigBee process (i.e. ZigBee object instance) on one defined serial port. IRC #pocoo (12/09/14 ~ 4:00pm EST):
IRC #arduino (12/09/14 ~ 4:00pm EST):
IRC #raspberrypi (12/09/14 ~ 4:00pm EST):
IRC #python (12/09/14 ~ 4:00pm EST):
|
We need to store the
ZigBee
class instance in some cache, or the reference of the class in a database. This useful for cases where a user (via web-interface, or http request) connects to an xbee device, and there exists a limit for the number of connections allowed.If such is the case, we need to research if python can store the
ZigBee
instance, so that, if the number of unique connections reaches a limit, to not issue moreZigBee
connections (to the desired device). This will be done (if possible) by counting the number of activeZigBee
processes, either from a database or system cache.The text was updated successfully, but these errors were encountered: