I ran into some strange errors and just ask myself if I have a fundamental issue in my class hierarchy. I am an absolute newbie if it comes to python. So if this approach appears llike total crap - you know why that is :-)
I have a couple of classes in an application I designed around the MVC pattern. The applications controller has control over four objects I call 'devices', since they act like independant devices. Each device runs actions (computations), image processing in this case. Those actions are meant to run inside separate threads. So each device should open an 'own' thread and have its computation done in that thread.
For this I designed a base class describing a 'device', so all devices inherit their basic setup and logic, especially the way they are controlled by the controller. For the threads I implemented a 'worker' class, I plan to push that classes instances into the threads. That part is not working yet. Those worker classes are designed like this: The base device class contains a nested worker base class. It also implements some basic control methods to handle a worker instance that is stored as a member of the base device class. All specialized device classes (derived from the base device class) also implement a nested worker class. Those classes are derived from the base worker class nested inside the base device class. Here is a sketch of the hierarchy:
/class Device/
/methods
/members
/class Worker/
/methods
/members
/class fooDevice(Device)/
/methods
/members
/class fooWorker(Device.Worker)/
/methods
/members
/class barDevice(Device)/
/methods
/members
/class barWorker(Device.Worker)/
/methods
/members
Note that the classes fooWorker
and barWorker
are both derived from Device.Worker
!
My question is: although the stuff appears to work during setup I get runtime errors. not sure yet where they come from, what they mean. But first I want to understand of that class hierarchy layout I made up does make sense at all? Is it totally twisted nonsense? Or in common use?
Thanks!