Understanding HandleCount in python [closed]

asked 2020-12-14 08:07:17 -0500

I was trying to understand handles and handle count in python.

I opened a file with python and was expecting the handle count to increase since the file is still open. But the handle count remained the same.

C:\Users\achakravarthy>py Python 3.7.2 (tags/v3.7.2:9a3ffc0492, Dec 23 2018, 23:09:28) [MSC v.1916 64 bit (AMD64)] on win32 Type "help", "copyright", "credits" or "license" for more information.

import os os.getppid() 12688 PS C:\Users\achakravarthy> get-process -id 12688 | select-object Handle, HandleCount
Handle HandleCount


5116 142 I opened a file and wrote a text. The file is still open. I was expecting the handle count to increase to 143 since the process still has the file open.

f = open( 'test.txt', 'w+' ) f.write('hello world') 11 But HandleCount remains the same (142). The handle value was however changing randomly.

PS C:\Users\achakravarthy> get-process -id 12688 | select-object Handle, HandleCount
Handle HandleCount


1528 142 Can someone please help understand/educate with resources on why handlecount does not increase on opening a file and why handle value keeps changing randomly.

edit retag flag offensive reopen merge delete

Closed for the following reason question is off-topic or not relevant. Please see http://wiki.ros.org/Support for more details. by jarvisschultz
close date 2020-12-14 08:57:10.900828

Comments

This question is a pure Python question and is not related to ROS in any way. I'd recommend asking this in a more appropriate place such as https://stackoverflow.com/

jarvisschultz gravatar image jarvisschultz  ( 2020-12-14 08:58:12 -0500 )edit