Python Forum
how to keep a Popen instance existant in a function return?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
how to keep a Popen instance existant in a function return?
#1
i have a function that is intended to start a subprocess.Popen instance and return the file object reference of the read end of the stdout pipe of that process. normally i can read this file OK. but this fails when created in a function. i have determined that the cause is the Popen instance object is dereferenced when the function returns resulting in the file object being return is now closed. the caller tries to read it and gets the exception "ValueError: I/O operation on closed file."

how can i prevent the Popen instance object from being dereferenced?
Tradition is peer pressure from dead people

What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
Reply


Messages In This Thread
how to keep a Popen instance existant in a function return? - by Skaperen - Sep-17-2020, 01:15 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  nested function return MHGhonaim 2 624 Oct-02-2023, 09:21 AM
Last Post: deanhystad
  return next item each time a function is executed User3000 19 2,314 Aug-06-2023, 02:29 PM
Last Post: deanhystad
  function return boolean based on GPIO pin reading caslor 2 1,193 Feb-04-2023, 12:30 PM
Last Post: caslor
  return vs. print in nested function example Mark17 4 1,757 Jan-04-2022, 06:02 PM
Last Post: jefsummers
  How to invoke a function with return statement in list comprehension? maiya 4 2,868 Jul-17-2021, 04:30 PM
Last Post: maiya
  Function - Return multiple values tester_V 10 4,470 Jun-02-2021, 05:34 AM
Last Post: tester_V
  Get return value from a threaded function Reverend_Jim 3 17,157 Mar-12-2021, 03:44 AM
Last Post: Reverend_Jim
  Return not exiting function?? rudihammad 3 5,310 Dec-01-2020, 07:11 PM
Last Post: bowlofred
  Why does my function return None? vg100h 3 2,227 Oct-29-2020, 06:17 AM
Last Post: vg100h
  Function will not return variable that I think is defined Oldman45 6 3,543 Aug-18-2020, 08:50 PM
Last Post: deanhystad

Forum Jump:

User Panel Messages

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