You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am wanting to make some changes to this library that will make it thread safe. While I know I am able to do this for my own use I wanted to know if I made a PR for the changes would there be an interest in adding them to this library?
This would be my game plan.
I am going to create an instance singleton meta class to handle the creation of a Blink1 instance. This will make it so that only a single instance for a blink1 device can exist at any given point. This will allow us to handle multiple threads accessing the device at the same time by using a thread lock in each instance.
Right now If I used this code there would be a problem.
the way the current library is coded an exception would occur if a Blink1 instance gets created more then one time for a device with the same serial number. what should happen is if an instance for a device already exists then that instance should be returned. designing it this way has a series of benefits. A user would not have to keep reference to an instance at all. successive calls to Blink1.__init__ would return an instance of Blink1 if it already exists. we can also get creative with the Blink1 class by coding it so that it is a device and also an enumeration of all devices at the same time.
I will hammer together something and show you the code to see if it is something you like.
The text was updated successfully, but these errors were encountered:
This sounds like a good idea. I've used similar singleton concepts in other blink(1) libraries. I admit to not being very Python-literate so if you can provide guidance here, I would much appreciate it.
I am wanting to make some changes to this library that will make it thread safe. While I know I am able to do this for my own use I wanted to know if I made a PR for the changes would there be an interest in adding them to this library?
This would be my game plan.
I am going to create an instance singleton meta class to handle the creation of a Blink1 instance. This will make it so that only a single instance for a blink1 device can exist at any given point. This will allow us to handle multiple threads accessing the device at the same time by using a thread lock in each instance.
Right now If I used this code there would be a problem.
the way the current library is coded an exception would occur if a Blink1 instance gets created more then one time for a device with the same serial number. what should happen is if an instance for a device already exists then that instance should be returned. designing it this way has a series of benefits. A user would not have to keep reference to an instance at all. successive calls to Blink1.__init__ would return an instance of Blink1 if it already exists. we can also get creative with the Blink1 class by coding it so that it is a device and also an enumeration of all devices at the same time.
I will hammer together something and show you the code to see if it is something you like.
The text was updated successfully, but these errors were encountered: