" '<client_name_here>' has no attribute '_lock' " when trying to run sample that uses installed client

  • I have created a custom Python OpenDXL client using the bootstrapper (which I found here: OpenDXL Bootstrap Application.). The intention is to use this client to send requests to a service on the DXL fabric and get a response. To test it, I modified the built-in sample that comes with bootstrap-generated files.


    When I run my code using python -m P2InternalClient <config-directory> I don't have any problems and everything works perfectly fine. However, I want to use this as an installed library that can have a client that extends the P2InternalClient to use as a normal DXL client.


    I used the bootstrap distribution script to create a .whl and install it using PIP without any problem. However, when I try to use the modified sample code to import the installed module, I get this error:

    [IMG:https://i.imgur.com/GCGunXQ.png]


    I have no idea what this is referring to with the _lock attribute.


    Client Code:

    If it helps, I've included a version of the client class that can cause the issue (see below)


    Sample Code:

    And once the library is installed, here is the sample code that causes the error.


    I'm pretty stumped on this, does anyone have any idea what the problem is?

  • It looks like you are trying to use an application generated by OpenDXL Bootstrap's application-template generation function, rather than a client based on the client-template. This is apparent for two reasons: the name of your client file is app.py, which is the default name of the client file created by the application template, and this error in your output:


    TypeError: object of type 'DxlClient' has no len()


    This is a result of the difference in the __init__ used for OpenDXL Bootstrap application templates and client templates.


    In the application template, the __init__ for your client will look like this:

    Python: open-dxlbootstrap-python/dxlbootstrap/app.py
    1. def __init__(self, config_dir, app_config_file_name):
    2. """
    3. Constructs the application
    4. :param config_dir: The directory containing the application configuration files
    5. :param app_config_file_name: The name of the application-specific configuration file
    6. """


    In the client template, it will look like this:

    Python: opendxl-bootstrap-python/dxlbootstrap/client.py
    1. def __init__(self, dxl_client):
    2. """
    3. Constructor parameters:
    4. :param dxl_client: The DXL client to use for communication with the fabric
    5. """


    As you can see, the constructor in the application template does not take in a DxlClient as an argument, and is instead attempting to use the DxlClient you passed it as a file path.



    The Fix:
    The simplest way to fix this issue would be to generate a new client template using the instructions found here: OpenDXL Bootstrap Tutorial Part 4: Create Client Wrapper.