I have a celery task that is calling a django management command using call_command and that management command uses the python logging framework to create a TimedRotatingFileHandler.
On a windows test station, I am getting the following stack trace which seems to show that the celery tasks are still holding the log file handle open after they have completed:
Traceback (most recent call last):
File "C:\Python27\lib\logging\handlers.py", line 77, in emit
self.doRollover()
File "C:\Python27\lib\logging\handlers.py", line 350, in doRollover
os.rename(self.baseFilename, dfn)
WindowsError: [Error 32] The process cannot access the file because it is being used by another process
Logged from file myCommand.py, line XX
Is this a known issue and if so is there a method for getting around it? (I have tried googling but could not find anything relevant).
Related
We are working on this reinforcement learning project here and we used GitHub Actions to build our testing CI system. Basically, we run unit tests with GitHub Actions on linux and macos. We find that the error below randomly occurs on macos.(It can pass when we rerun the job manually.) We cannot reproduce the error on our local machine. The corresponding unit test is here
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/usr/local/miniconda/lib/python3.9/multiprocessing/spawn.py", line 116, in spawn_main
exitcode = _main(fd, parent_sentinel)
File "/usr/local/miniconda/lib/python3.9/multiprocessing/spawn.py", line 126, in _main
self = reduction.pickle.load(from_parent)
File "/usr/local/miniconda/lib/python3.9/site-packages/torch/multiprocessing/reductions.py", line 322, in rebuild_storage_filename
storage = torch.UntypedStorage._new_shared_filename_cpu(manager, handle, size)
RuntimeError: Connection refused
I'd like to know: 1. Has someone encountered this before? 2. Is this caused by our side or the GitHub Actions side? 2. If it is caused by our side, how can we debug it(since GitHub Actions is a black box to us and we cannot reproduce it locally)? 3. If it is caused by the GitHub Actions side, is there an elegant way to deal with it?
I'm trying to setup running google tests on a C++ repository using Github Actions that are running on Windows Latest.
The building process completes, but when it comes to running the tests - it is stuck and doesn't execute the executable, that is generated from the Visual Studio Project via msbuild. Generally the tests should execute in a close to none amount, since there are not a lot of tests. I have also waited and 30 minutes for the action to execute, but no luck.
What I have tried is:
Running the executable straight from the actions.yml file like:
Build/Tests.exe
Build/Tests
./Build/Tests
./Build/Tests.exe
cd Build && Tests.exe
etc.
Some of these commands run and execute locally, but are stuck on execute on the Github Actions Runner.
Now I have switched to a python script running these commands for maybe getting more insight on the process and seems when calling subprocess.Popen, the action is still stuck, but on wait.
Workflow callstack after canceling the workflow:
Run python Tools/test.py
python Tools/test.py
shell: C:\Program Files\PowerShell\7\pwsh.EXE -command ". '{0}'"
env:
CMAKE_VERSION: 3.21.1
NINJA_VERSION: 1.10.2
pythonLocation: C:\hostedtoolcache\windows\Python\3.10.2\x64
^CTraceback (most recent call last):
File "D:\a\Lib\Lib\Tools\test.py", line 48, in <module>
sys.exit(main())
File "D:\a\Lib\Lib\Tools\test.py", line 44, in main
return run(cmd_arguments)
File "D:\a\Lib\Lib\Tools\test.py", line 39, in run
return process.communicate()[0]
File "C:\hostedtoolcache\windows\Python\3.10.2\x64\lib\subprocess.py", line 1141, in communicate
self.wait()
File "C:\hostedtoolcache\windows\Python\3.10.2\x64\lib\subprocess.py", line 1204, in wait
return self._wait(timeout=timeout)
File "C:\hostedtoolcache\windows\Python\3.10.2\x64\lib\subprocess.py", line 1485, in _wait
result = _winapi.WaitForSingleObject(self._handle,
KeyboardInterrupt
I have one Github project, I cloned it locally using pycharm IDE and installed all the packages to run the project successfully. When I try to build the solution, getting the exception as host alias is not in environment.
below is the exception detail.
`Unhandled exception in thread started by <function fn at 0x7fa22ef08e60>
Traceback (most recent call last):
File "./runner.py", line 20, in fn
subprocess.call(command.split(" "), cwd = directory)
File "/usr/lib/python2.7/subprocess.py", line 523, in call
return Popen(*popenargs, **kwargs).wait()
File "/usr/lib/python2.7/subprocess.py", line 711, in __init__
errread, errwrite)
File "/usr/lib/python2.7/subprocess.py", line 1343, in _execute_child
raise child_exception
OSError: [Errno 2] No such file or directory
BUILD_NUMBER: 1390
FATAL ERROR: FEED_HOST_ALIAS not in environment
BUILD_NUMBER: 1390
FATAL ERROR: FEED_HOST_ALIAS not in environment
BUILD_NUMBER: 1390
FATAL ERROR: FEED_HOST_ALIAS not in environment`
OS version: Ubuntu 16.04 LTS
Python version: 2.7.10
Let's sort things out.
this is problem running the application. You don't "build" python applications
this seems to be a multithreaded application. Therefore there may be output from different threads.
in line 20 of your file ./runner.py you call subprocess.call().
that call internally calls some other things (Popen() and _execute_child()), but the final action is to raise an exception telling you No such file or directory.
since the subproces.call() call ends at that point, it is likely that the other output is from another thread. You could search your solution for the string 'FEED_HOST_ALIAS', but my guess is that this message is not directly related to the problem.
The problem is, as subprocess.call() reports, that the file you are asking to run does not exist. So set a breakpoint in runner.py at line 20 and have a look at what is passed as parameters. Then you should find out what happens. PyCharm lets you step into calls, so you might even want to check what happens inside subprocess.call() - or place a breakpoint somewhere within subprocess.py.
i have web app that i have developed using bottle micro framework.
However it crash a lot and all of them suddenly without any action ( without using the web app) . So i have reviewed the logs file and find the following errors (i have no idea what the causation of these errors):
Traceback (most recent call last):
File "/home/hamoud/lib/python2.7/bottle.py", line 2699, in run
server.run(app)
File "/home/hamoud/lib/python2.7/bottle.py", line 2385, in run
srv = make_server(self.host, self.port, handler, **self.options)
File "/usr/local/lib/python2.7/wsgiref/simple_server.py", line 144, in make_server
server = server_class((host, port), handler_class)
File "/usr/local/lib/python2.7/SocketServer.py", line 419, in __init__
self.server_bind()
File "/usr/local/lib/python2.7/wsgiref/simple_server.py", line 48, in server_bind
HTTPServer.server_bind(self)
File "/usr/local/lib/python2.7/BaseHTTPServer.py", line 108, in server_bind
SocketServer.TCPServer.server_bind(self)
File "/usr/local/lib/python2.7/SocketServer.py", line 430, in server_bind
self.socket.bind(self.server_address)
File "/usr/local/lib/python2.7/socket.py", line 224, in meth
return getattr(self._sock,name)(*args)
TypeError: 'int' object is not callable
and
Traceback (most recent call last):
File "interface.py", line 29, in <module>
run(host="localhost", port=32471, reloader=True, debug=True)
File "/home/hamoud/lib/python2.7/bottle.py", line 2657, in run
os.utime(lockfile, None) # I am alive!
OSError: [Errno 2] No such file or directory: '/tmp/bottle.gQmJc8.lock'
However the second error doesn't crash the application ( application would continue working ) but for the first one it's require manual work ( run the app again ).
i could schedule task using cron job to run the application when it's crash. but i'd like to know what's the problem in my app.
A few ideas come to mind:
Could there be another program on your machine (e.g., a cron job) that is deleting files from /tmp?
Are you using the latest version of Bottle? (From the line number in your stacktrace, it looks like you might not be.)
If nothing else works, try running without reloader=True (or use reloader=False). I looked at the Bottle code, and that change should at least work around the problem, even though we don't know the cause (yet).
Hope that helps.
I've been having some very weird problems. Yesterday I updated my master branch on a project and after that, when I tried to do manage.py runserver the runserver wouldn't serve any page. I had to ctrl + c to exit the server and I would later receive this message.
Exception happened during processing of request from ('127.0.0.1', 53975)
Unhandled exception in thread started by <function inner_run at 0x2ec8488>
Traceback (most recent call last):
File "/home/marco/virtualenvs/designersenv/lib/python2.7/site-packages/django/core/management/commands/runserver.py", line 60, in inner_run
run(addr, int(port), handler)
File "/home/marco/virtualenvs/designersenv/lib/python2.7/site-packages/django/core/servers/basehttp.py", line 721, in run
httpd.serve_forever()
File "/usr/lib/python2.7/SocketServer.py", line 227, in serve_forever
self._handle_request_noblock()
File "/usr/lib/python2.7/SocketServer.py", line 286, in _handle_request_noblock
self.handle_error(request, client_address)
File "/usr/lib/python2.7/SocketServer.py", line 342, in handle_error
import traceback
ImportError: No module named traceback
I found out by experimentation that erasing the database(sqlite) and recreating it with syncdb and migrate removed the issue, but once I add something to the models via the admin page, I would get the same error again, no pages would be served.
I also noticed that when this was going on, python starting to occupy around 40-60% of my CPU and RAM. I later noticed on the project folder, where database.db is located, a database.db-journal file would be created every 2-3 seconds, get deleted and then reappear. Googling didn't bring me any results so I am laying my hands on SO wisdom. Thanks.
I can see you are running in a virtual enviroment. It's possible that it became corrupted while downloading. I would recreate it from scratch.
Also, check in that enviroment shell if you can import traceback and check outside the enviroment too. It may give you some clues.
disclaimer: this answer is 90% intuition, sorry :/
A couple months late but anyway, here is what my problem was:
A django app was messing up and getting stuck in a bug. I believe it was Django Cache Bot.
Cheers.