Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

AttributeError: module 'hl7apy.v2_5' has no attribute 'get'

See original GitHub issue

I am seeing the following error/stacktrace when using hl7apy in a REST API written in Python3.7, running on a Flask/Gunicorn web server with 2 worker processes and multiple threads per worker.

Traceback (most recent call last):
  File "venv/lib/python3.7/site-packages/flask/", line 1813, in full_dispatch_request
    rv = self.dispatch_request()
  File "venv/lib/python3.7/site-packages/flask/", line 1799, in dispatch_request
    return self.view_functions[rule.endpoint](**req.view_args)
  File "/", line 189, in wrapped_f
    return f(*args, **kwargs)
  File "", line 60, in receive_message
    parsed_message = parse(appt_msg_hl7)
  File "hl7/", line 50, in parse
    return parse_message(message.replace('\n', '\r'), find_groups=False)
  File "venv/lib/python3.7/site-packages/hl7apy/", line 82, in parse_message
    validation_level=validation_level, encoding_chars=encoding_chars)
  File "venv/lib/python3.7/site-packages/hl7apy/", line 1914, in __init__
  File "venv/lib/python3.7/site-packages/hl7apy/", line 1784, in __init__
    super(Group, self).__init__(name, parent, reference, version, validation_level, traversal_parent)
  File "venv/lib/python3.7/site-packages/hl7apy/", line 638, in __init__
  File "venv/lib/python3.7/site-packages/hl7apy/", line 813, in _find_structure
    structure = ElementFinder.get_structure(self, reference)
  File "venv/lib/python3.7/site-packages/hl7apy/", line 546, in get_structure
    reference = load_reference(, element.classname, element.version)
  File "venv/lib/python3.7/site-packages/hl7apy/", line 280, in load_reference
    ref = lib.get(name, element_type)
AttributeError: module 'hl7apy.v2_5' has no attribute 'get'

Some other useful information:

  • I am able to successfully parse the offending messages on my local setup, so this only seems to happen in my multithreaded production environment.
  • This error also occurs with hl7apy.v2_4, so it is not peculiar to hl7apy.v2.5.
  • This problem is intermittent i.e. messages are parsed successfully 90% of the time, but there are a few so-far-unpredictable instances where this error occurs at runtime.

Could it be that certain aspects of the hl7apy implementation are not thread-safe? Is hl7apy thread-safe? Or is this caused by something else entirely that I may be overlooking? Please help!

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

shamim40commented, Oct 27, 2021

I appreciate ur quick response. What is the timeline for the release?

svituzcommented, Oct 27, 2021

Hi @shamim40, the multithreading issue is fixed in the develop branch, but we have not released it yet. If you want you can use it by cloning this repo, moving to the develop branch and installing the library from it.

Read more comments on GitHub >

github_iconTop Results From Across the Web

AttributeError: module XX has no attribute 'get' - Stack Overflow
Try this for Opera: from selenium import webdriver browser = webdriver.Opera() url = "" browser.get(url).
Read more >
HL7apy - a lightweight Python library to parse, create and ...
HL7apy is a lightweight Python package to intuitively handle HL7 v2 messages according to HL7 specifications. The main features includes: ... This project...
Read more >
HL7apy Documentation - Read the Docs
HL7apy provides an implementation of MLLP server that can be found in the module hl7apy.mllp. To manage different types of incoming messages, it ......
Read more >
How to Resolve Module Has No Attribute - Python Error ...
In this tutorial I will be showing you how to MANAGE THE " MODULE HAS NO ATTRIBUTE" ERROR MESSAGE using Python. This is...
Read more >
[Solved] AttributeError: 'module' object has no attribute
Click here to subscribe -▻Instagram ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Post

No results found

github_iconTop Related Hashnode Post

No results found