Go Back   Cockos Incorporated Forums > REAPER Forums > ReaScript, JSFX, REAPER Plug-in Extensions, Developer Forum

Reply
 
Thread Tools Display Modes
Old 07-19-2019, 12:35 AM   #1
ausbaxter
Human being with feelings
 
Join Date: Apr 2016
Posts: 39
Default Error running lua script. 'cannot open [script.lua]: Too many open files'

Hey all,

Ran into this error today that I've never seen before:



Has anyone ever experienced this before?

I've tried to reproduce it on two different systems (OSX Mojave, and Win 10). This was originally experienced on an OSX El Capitan (don't have access to that computer right now so I don't have the exact version number).

Can't seem to find anything pertaining to this error on the forum. Gonna do some troubleshooting tomorrow.
ausbaxter is offline   Reply With Quote
Old 07-19-2019, 02:51 AM   #2
X-Raym
Human being with feelings
 
X-Raym's Avatar
 
Join Date: Apr 2013
Location: France
Posts: 9,875
Default

This can happen if your script have io.open files but no file:close() after... Theb it leave open files and if your scripts parse a lot of files, it can be problematic.
Maybe also with GetSource function if source isnt deleted despite file isnt in the project.


Check for things like this :P
X-Raym is offline   Reply With Quote
Old 07-19-2019, 07:30 AM   #3
ausbaxter
Human being with feelings
 
Join Date: Apr 2016
Posts: 39
Default

Thanks for the quick reply X-Raym!

Quote:
Originally Posted by X-Raym
This can happen if your script have io.open files but no file:close() after...
I have a persistent script running in the background that use the io library, but I do close the file after read or write when using io.open. There's also use of io.lines which should close files after leaving the loop scope.

The issue may be heavy reading/writing of projextstate. I am (naively) using it as a workaround for not having global memory... which is no longer an issue as of 5.980. Still a bit odd because the error isn't thrown from the deferred scripts.
ausbaxter is offline   Reply With Quote
Old 07-19-2019, 07:48 AM   #4
Meo-Ada Mespotine
Human being with feelings
 
Meo-Ada Mespotine's Avatar
 
Join Date: May 2017
Location: Leipzig
Posts: 6,621
Default

If you use my Ultraschall-API, you can use ultraschall.ReadFullFile. This automatically closes the file so you don't need to take care of that.
I love that, as I'm lazy as hell

https://mespotin.uber.space/Ultrasch...l#ReadFullFile

@X-Raym
Do you know the limit of how many files can be opened at the same time?
__________________
Use you/she/her.Ultraschall-Api Lua Api4Reaper - Donate, if you wish

On vacation for the time being...
Meo-Ada Mespotine is offline   Reply With Quote
Old 07-19-2019, 09:40 AM   #5
X-Raym
Human being with feelings
 
X-Raym's Avatar
 
Join Date: Apr 2013
Location: France
Posts: 9,875
Default

Quote:
Do you know the limit of how many files can be opened at the same time?

I think it is system dependant (os + hardware) but I am not sure. It is not a bug we faced often.


Quote:
Still a bit odd because the error isn't thrown from the deferred scripts.
Yes, but maybe this defer script talk all the "slots" avaoble, so the error is trigger when a new scripts is launched.


Anyway, avoid io functions in defer scripts, it is way safer :P
X-Raym is offline   Reply With Quote
Old 07-22-2019, 02:13 PM   #6
Meo-Ada Mespotine
Human being with feelings
 
Meo-Ada Mespotine's Avatar
 
Join Date: May 2017
Location: Leipzig
Posts: 6,621
Default

Hmm...that means, I should build into my API a way to catch this error properly...


Now I need to open gazillions of files for one workaround O_O
__________________
Use you/she/her.Ultraschall-Api Lua Api4Reaper - Donate, if you wish

On vacation for the time being...
Meo-Ada Mespotine is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -7. The time now is 11:00 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.