Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test_activate_operation_updates_active_users needs a review #2546

Open
ReimarBauer opened this issue Oct 4, 2024 · 8 comments
Open

test_activate_operation_updates_active_users needs a review #2546

ReimarBauer opened this issue Oct 4, 2024 · 8 comments
Labels

Comments

@ReimarBauer
Copy link
Member

I see this sometimes on my local tests

[gw5] [100%] PASSED tests/_test_msui/test_mscolab.py::Test_Mscolab::test_activate_operation_updates_active_users 

Exception ignored in: <function WMSControlWidget.__del__ at 0x718a67ac9120>
Traceback (most recent call last):
  File "/home/reimar/MAIN/MSS/mslib/msui/wms_control.py", line 550, in __del__
    self.service_cache()
  File "/home/reimar/MAIN/MSS/mslib/msui/wms_control.py", line 1455, in service_cache
    files = [os.path.join(self.wms_cache, f) for f in os.listdir(self.wms_cache)]
                                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^
FileNotFoundError: [Errno 2] Datei oder Verzeichnis nicht gefunden: '/tmp/tmpnodr4uwv/msui/wms_cache/'
@ReimarBauer
Copy link
Member Author

@Pavanbhagi
Copy link

import os

class WMSControlWidget:
def init(self, wms_cache):
self.wms_cache = wms_cache
os.makedirs(self.wms_cache, exist_ok=True) # Ensure the cache directory exists

def service_cache(self):
    if os.path.exists(self.wms_cache):
        files = [os.path.join(self.wms_cache, f) for f in os.listdir(self.wms_cache)]
        # ... process files
    else:
        files = []  # Handle the case where the directory does not exist

def __del__(self):
    # Consider removing any critical logic here or checking for existence
    try:
        self.service_cache()
    except Exception as e:
        # Log the exception if necessary
        pass

@ReimarBauer
Copy link
Member Author

Not each test is failing. On production I don't have seen that problem. We need to investigate why in this order of tests the problem occures and likly improve a test.

@Abhisek-exe
Copy link

Hey @ReimarBauer , I could not reproduce the issue. Can you please help with this.

When I ran pytest test_mscolab.py I got these results
Screenshot 2024-11-30 144816
Screenshot 2024-11-30 144842

@Abhisek-exe
Copy link

just a follow up mention @ReimarBauer can you look into this please!

@ReimarBauer
Copy link
Member Author

This error happens randomly in parallel testing. It is not easy to catch.

@sagarchauhan2004
Copy link

Modify the service_cache method to check if the directory exists before trying to list its files.

import os

def service_cache(self):
if os.path.exists(self.wms_cache) and os.path.isdir(self.wms_cache):
files = [os.path.join(self.wms_cache, f) for f in os.listdir(self.wms_cache)]
# proceed with your logic here
else:
print(f"Directory {self.wms_cache} does not exist.")

@ReimarBauer
Copy link
Member Author

That is not the solution because the problem seems only to occure in the tests on parallel testing. I believe we need to find the test which is the reason for this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants