You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently we put imported libraries into an internal cache to avoid importing and processing them multiple times. It's questionable how much time that actually saves and there's a risk that we waste memory keeping references to libraries used only once. The cache also makes the overall import logic more complicated and causes bugs like #2105. Need to measure what kind of performance changes removing the cache would have.
We are also thinking about not caching resources (#2099) and variable files (#2101).
This would be clearer indeed but could break things (triggered by #2165) - some things to consider :
use cache when imported with Library KW in *** Settings ***?
optionally use cache when imported with BuiltIn.Import Library KW (e.g. with force_reimport=False arg?
I have for example many resource files with possible duplicate imports Libs e.g.
a) MyRes_A uses My_Lib_1 and MyRes_C
b) MyRes_B uses MyRes_C
c) MyRes_C uses My_Lib_1
Scenario a) would import My_Lib_1 twice. This could become problematic if the My_Lib_1 is stateful and is imported with BuiltIn.Import Library
I would rather have a solution that works out-of-the-box and doesn't require uses to know some special flag. Another problem is that libraries themselves can accept arguments and they can conflict with such special flags. We already have WITH NAME flag, but I would like to limit them only to cases where we really need them.
Removed from RF 5.0 scope simply because there are so many other more important enhancements. Another reason is that there probably aren't other changes that would affect the related code. Better to have a release where one of the main topics is enhancing importing and storing libraries as well as resource and variable files.
I was having a similar issue with the importing of libraries. Ideally when a class is imported as Library it will call __init__ and supply the argument to it if any. But if it is already imported with similar arguments it will not reimport instead it takes from cache.
Now if the ROBOT_LIBRARY_SCOPE = 'GLOBAL' I would agree that the library can be cached, but if the scope has been changed 'SUITE'or TEST it should import the library again irrespective of whether it is caches or not for suites or test respectively.
For my case I wanted the import to happen for each robot file in a folder, even though I had set the scope of library to SUITE. It was taking it from cache and so __init__ was never called.
Is this the current expected behavior? If yes I would argue that this should be brought to the release scope so it does not takes from cache and takes into account the library's scope.
Activity
[-]Imported libraries should be cached[/-][+]Imported libraries should not be cached[/+]yahman72 commentedon Oct 9, 2015
This would be clearer indeed but could break things (triggered by #2165) - some things to consider :
LibraryKW in*** Settings ***?BuiltIn.Import LibraryKW (e.g. withforce_reimport=Falsearg?I have for example many resource files with possible duplicate imports Libs e.g.
a)
MyRes_AusesMy_Lib_1andMyRes_Cb)
MyRes_BusesMyRes_Cc)
MyRes_CusesMy_Lib_1Scenario a) would import
My_Lib_1twice. This could become problematic if theMy_Lib_1is stateful and is imported withBuiltIn.Import Librarystasiek commentedon Nov 19, 2015
How about some flag-parameter for
Libraryto make sure the import is fresh?Like
Library SwingLibrary FRESHpekkaklarck commentedon Nov 19, 2015
I would rather have a solution that works out-of-the-box and doesn't require uses to know some special flag. Another problem is that libraries themselves can accept arguments and they can conflict with such special flags. We already have
WITH NAMEflag, but I would like to limit them only to cases where we really need them.pekkaklarck commentedon Feb 4, 2017
#2377 contains a related request to allow importing different libraries using same name. Need to think about these together.
pekkaklarck commentedon Oct 3, 2018
#2931 is also somewhat related. It was closed because we already have this issue.
pekkaklarck commentedon Aug 15, 2019
#3249 demonstrates another problem caused by library cache. Let's try to get this fixed in RF 3.2.
pekkaklarck commentedon Aug 15, 2019
Should also look at #2377 when implementing this.
pekkaklarck commentedon Nov 8, 2019
RF 3.2 is so long overdue that this is unfortunately descoped. If someone would really like this in, please comment here.
pekkaklarck commentedon Sep 24, 2021
Removed from RF 5.0 scope simply because there are so many other more important enhancements. Another reason is that there probably aren't other changes that would affect the related code. Better to have a release where one of the main topics is enhancing importing and storing libraries as well as resource and variable files.
tauzahmd commentedon Jul 15, 2022
I was having a similar issue with the importing of libraries. Ideally when a class is imported as
Libraryit will call__init__and supply the argument to it if any. But if it is already imported with similar arguments it will not reimport instead it takes from cache.Now if the
ROBOT_LIBRARY_SCOPE = 'GLOBAL'I would agree that the library can be cached, but if the scope has been changed'SUITE'orTESTit should import the library again irrespective of whether it is caches or not for suites or test respectively.For my case I wanted the import to happen for each robot file in a folder, even though I had set the scope of library to
SUITE. It was taking it from cache and so__init__was never called.Is this the current expected behavior? If yes I would argue that this should be brought to the release scope so it does not takes from cache and takes into account the library's scope.
franzhaas commentedon Jan 21, 2025
This is somewhat linked to this topic as well.: #5122 however this is just a documentation clarification... much less impact