Python Forum
Killing processes via python
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Killing processes via python
#1
Hello,

my knowledge of python is rather limited so I might just be poking in the dark...

What I am attempting to do is open a file, write some stuff in it and close it.

The problem I have is, what if that file is opened?

To fit my needs, it needs to be closed, no matter what's happening to it, so I can open it via python application.

So if I cant open a file that's open, I can try to force close it and then open it via python?

Found this lib: https://psutil.readthedocs.io/en/latest/

It kind of does what I want, maybe I'm just missing on the how.

It currently returns me a list of all processes, and gives me ids that I can use to kill processes.

While in reality, I would like to close test.csv that is open in excel instead of closing all of excel, any ideas how I
can achieve that?
Reply


Messages In This Thread
Killing processes via python - by Lavina - Jun-15-2020, 02:24 PM
RE: Killing processes via python - by DeaD_EyE - Jun-16-2020, 04:37 PM
RE: Killing processes via python - by warnerarc - Aug-04-2021, 06:20 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  processes shall be parallel flash77 4 2,131 Sep-20-2022, 11:46 AM
Last Post: DeaD_EyE
  sharing variables between two processes Kiyoshi767 1 2,659 Nov-07-2020, 04:00 AM
Last Post: ndc85430
  2 or more processes on the write end of the same pipe Skaperen 4 6,115 Sep-27-2020, 06:41 PM
Last Post: Skaperen
  Errors using --processes parameter sonhospa 3 3,425 Jul-01-2020, 02:24 PM
Last Post: sonhospa
  cv2.resize(...) shutting down processes? DreamingInsanity 1 3,189 Dec-18-2019, 04:06 PM
Last Post: DreamingInsanity
  waiting for many processes in parallel Skaperen 2 2,633 Sep-02-2019, 02:20 AM
Last Post: Skaperen
  how to clean up unstarted processes? Skaperen 2 3,104 Aug-27-2019, 05:37 AM
Last Post: Skaperen
  waiting for a mix of file and processes Skaperen 0 1,999 Jul-28-2019, 06:58 AM
Last Post: Skaperen
  how to terminate all the processes in C py2exe 0 2,583 Aug-02-2018, 04:31 AM
Last Post: py2exe
  How to run different processes in a pool of 5 lravikumarvsp 0 2,802 May-29-2018, 09:43 AM
Last Post: lravikumarvsp

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020