There seems to be a discrepency - on my machine at least - between files in use under iconx and those reported by lsof. I don't know how the interaction between the two works, but I would've expected lsof to get the info from the OS, so I'm not sure what's going on here. I don't want to post it as a unicon bug if it's lsof, and vice versa, so any help pinning this down would be appreciated.
I was gettng "open files" errors under linux due to extremely lazy and inefficient coding on my part - I'll redo this later - and was using lsof to look at what was going on.
The code basically looked like this (with functions omitted):
globalmerged_fileproceduremain()merged_file:=open("test_merged.csv","w")|stop(&errortext," merged_file")DoFileMerge()close(merged_file)endprocedureDoFileMerge()main_file:=open("test_main.csv","r")|stop(&errortext," main_file")whileEachLineOfMain(read(main_file))close(main_file)endprocedureEachLineOfMain(main_line)steamer_file:=open("test_steamers.csv","r")|stop(&errortext," steamer_file")drifter_file:=open("test_drifters.csv","r")|stop(&errortext," drifter_file")steamer_list:=[]whileline:=read(steamer_file)doput(steamer_list,line)drifter_list:=[]#while line := read(drifter_file) do put(drifter_list, line)close(steamer_file,drifter_file)#close(steamer_file)whileeveryWriteIfFound(main_line,!steamer_list)#while every WriteIfFound(main_line, !drifter_list)returnend
I had commented out drifter_file usage as that was where the open files error was apparently being reached.
Running the program however had lsof reporting lots of open files - in drifter_file! If I exclude the open & close for drifter_file also, lsof does not report that steamer_file is in use, even though it obviously is...
Is this likely to be a unicon issue, or lsof?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
To add some info to this query, I have discovered that the problem isn't with lsof per se.
If I look at /proc/<pid>/fd for the running unicon process, this also appears to list the files incorrectly. There are many drifter_file entries showing, and one for steamer_file (although the steamer_file entry doesn't always appear!); I would expect either one for each, or many for each (depending on when Unicon releases the resources).</pid>
I'm guessing no-one else has seen anything like this?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
To make an attempt at finding the cause, I rewrote the above section of code in Python, and running lsof while the process runs shows just one entry for each of the four files, as I originally expected.
As I'm new to Unicon, I wondered if part of the cause of the issue was due to the return statement in EachLineOfMain? I added this as the while statement running EachLineOfMain would complete after only one file line without it.
Is that somehow causing Unicon not to tidy up after itself, or am I doing something else wrong to stop Garbage Collection working properly?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
the issue is that you are passing two files to one call close(). What makes you think you can do that? Do we have something wrong in the documantation that suggets that?
make two seperate calls to close() and that should fix it. Extra parameters to fucntions are usually ignored. So the second file was just being ignored here. If you prefere one call to close() you can do:
every close(f 1| f2)
[Edit] of course, this is still two calls to close(), but it allows to be more concise sometimes.
Last edit: Jafar 2018-02-08
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Thanks, Jafar. Not sure where I got that idea from...!
I started posting on a machine that wasn't logged into SF, and thought it would confuse matters if I suddenly started posting under a different ID - sorry.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
View and moderate all "Help Getting Started" comments posted by this user
Mark all as spam, and block user from posting to "Discussion"
There seems to be a discrepency - on my machine at least - between files in use under iconx and those reported by lsof. I don't know how the interaction between the two works, but I would've expected lsof to get the info from the OS, so I'm not sure what's going on here. I don't want to post it as a unicon bug if it's lsof, and vice versa, so any help pinning this down would be appreciated.
I was gettng "open files" errors under linux due to extremely lazy and inefficient coding on my part - I'll redo this later - and was using lsof to look at what was going on.
The code basically looked like this (with functions omitted):
I had commented out drifter_file usage as that was where the open files error was apparently being reached.
Running the program however had lsof reporting lots of open files - in drifter_file! If I exclude the open & close for drifter_file also, lsof does not report that steamer_file is in use, even though it obviously is...
Is this likely to be a unicon issue, or lsof?
View and moderate all "Help Getting Started" comments posted by this user
Mark all as spam, and block user from posting to "Discussion"
To add some info to this query, I have discovered that the problem isn't with lsof per se.
If I look at /proc/<pid>/fd for the running unicon process, this also appears to list the files incorrectly. There are many drifter_file entries showing, and one for steamer_file (although the steamer_file entry doesn't always appear!); I would expect either one for each, or many for each (depending on when Unicon releases the resources).</pid>
I'm guessing no-one else has seen anything like this?
View and moderate all "Help Getting Started" comments posted by this user
Mark all as spam, and block user from posting to "Discussion"
To make an attempt at finding the cause, I rewrote the above section of code in Python, and running lsof while the process runs shows just one entry for each of the four files, as I originally expected.
As I'm new to Unicon, I wondered if part of the cause of the issue was due to the return statement in EachLineOfMain? I added this as the while statement running EachLineOfMain would complete after only one file line without it.
Is that somehow causing Unicon not to tidy up after itself, or am I doing something else wrong to stop Garbage Collection working properly?
Can you please provide a mimial example to reproduce this issue, with the expected results and the actual results?
Thanks!
View and moderate all "Help Getting Started" comments posted by this user
Mark all as spam, and block user from posting to "Discussion"
Hi Jafar.
Minimal python program:
Waiting approx 5 secs then using:
Produces:
i.e. one entry per file.
An equivalent unicon program:
Produces an lsof output of:
So it looks as though unicon is releasing the first file, but not the second before repeating the loop.
mod necro-edit for the syntax colouring, as of 2020
Last edit: Brian Tiffin 2020-03-28
Now that it is short I can follow it :-).
the issue is that you are passing two files to one call close(). What makes you think you can do that? Do we have something wrong in the documantation that suggets that?
make two seperate calls to close() and that should fix it. Extra parameters to fucntions are usually ignored. So the second file was just being ignored here. If you prefere one call to close() you can do:
every close(f 1| f2)
[Edit] of course, this is still two calls to close(), but it allows to be more concise sometimes.
Last edit: Jafar 2018-02-08
BTW, if you login to SF then you can post directly without having your posts going through admin moderation and slowing them down sometimes.
View and moderate all "Help Getting Started" comments posted by this user
Mark all as spam, and block user from posting to "Discussion"
Thanks, Jafar. Not sure where I got that idea from...!
I started posting on a machine that wasn't logged into SF, and thought it would confuse matters if I suddenly started posting under a different ID - sorry.