My response to Te-Wei's review of ts_hexrotomm:
1. This use of metaclass=abc.ABCMeta is standard for the abc module.
It is true that the abc module also includes a parent class one can inherit from, instead. But I prefer the direct technique because:
- It makes it clear that a metaclass is being used, which means the user must be careful about multiple inheritance.
- It avoids one level if inheritance.
2. My pattern is as follows:
- Add a start_task attribute to any class that has an asynchronous start method.
- Have the object automatically start itself when constructed by having the constructor call self.start_task = asyncio.create_task(self.start()))
- This allows a user who creates an instance of the class call await myinstance.start_task to wait until the instance has fully started.
That is what is happening here. BaseCsc has an instance variable server that is a CommandTelemetryServer, which handles the communication between the cRIO and the CSC. BaseCsc.start is waiting for the server to finish starting.
3. Good point. I'll shorten the long ones (I found 3 instances).
For the record: within a package there is no need to provide the full namespace to get a working link, so just providing the class name is fine.
1. This is a in reference to an argument named CommandCode.
This follows the DM convention, which is to use CamelCase for variables that hold classes. One justification is that variable naming convention matches the type the variable holds, which makes the code a bit easier to read when one creates an instance of the class. And if nothing else, it may help avoid the mistake of providing an instance when a class is required. Here is a silly toy example:
def make_instance(argument, ClassArgument):