diff mbox series

[1/2] recipetool: use context manager for tinfoil to avoid hang

Message ID 20231007174701.1890063-1-chris.laplante@agilent.com
State New
Headers show
Series [1/2] recipetool: use context manager for tinfoil to avoid hang | expand

Commit Message

chris.laplante@agilent.com Oct. 7, 2023, 5:47 p.m. UTC
If you individually run some of the devtool selftests, e.g. with:

    oe-selftest -r devtool.DevtoolAddTests.test_devtool_add

then you bypass the sanity check in test_create_workspace that checks
for an existing workspace layer. Eventually, recipetool will be called
in a test, and tinfoil.prepare will fail. But because tinfoil.shutdown
doesn't get called, the thread spawned by bb.server.process.BBUIEventQueue
spins forever and recipetool never exits, hanging the test.

Signed-off-by: Chris Laplante <chris.laplante@agilent.com>
---
 scripts/recipetool | 16 +++++-----------
 1 file changed, 5 insertions(+), 11 deletions(-)

Comments

Alexandre Belloni Oct. 8, 2023, 9:02 p.m. UTC | #1
Hello Chris,

Thank you for your patches!

Could you remember changing your git config for your next submission:
https://docs.yoctoproject.org/next/contributor-guide/submit-changes.html#fixing-your-from-identity

Thanks!

On 07/10/2023 13:47:00-0400, Chris Laplante via lists.openembedded.org wrote:
> If you individually run some of the devtool selftests, e.g. with:
> 
>     oe-selftest -r devtool.DevtoolAddTests.test_devtool_add
> 
> then you bypass the sanity check in test_create_workspace that checks
> for an existing workspace layer. Eventually, recipetool will be called
> in a test, and tinfoil.prepare will fail. But because tinfoil.shutdown
> doesn't get called, the thread spawned by bb.server.process.BBUIEventQueue
> spins forever and recipetool never exits, hanging the test.
> 
> Signed-off-by: Chris Laplante <chris.laplante@agilent.com>
> ---
>  scripts/recipetool | 16 +++++-----------
>  1 file changed, 5 insertions(+), 11 deletions(-)
> 
> diff --git a/scripts/recipetool b/scripts/recipetool
> index e2d585d2c5..9eaecfbde6 100755
> --- a/scripts/recipetool
> +++ b/scripts/recipetool
> @@ -22,13 +22,6 @@ logger = scriptutils.logger_create('recipetool')
>  
>  plugins = []
>  
> -def tinfoil_init(parserecipes):
> -    import bb.tinfoil
> -    import logging
> -    tinfoil = bb.tinfoil.Tinfoil(tracking=True)
> -    tinfoil.logger.setLevel(logger.getEffectiveLevel())
> -    tinfoil.prepare(not parserecipes)
> -    return tinfoil
>  
>  def main():
>  
> @@ -67,8 +60,11 @@ def main():
>  
>      scriptutils.logger_setup_color(logger, global_args.color)
>  
> -    tinfoil = tinfoil_init(False)
> -    try:
> +    import bb.tinfoil
> +    with bb.tinfoil.Tinfoil(tracking=True) as tinfoil:
> +        tinfoil.logger.setLevel(logger.getEffectiveLevel())
> +        tinfoil.prepare(True)
> +
>          for path in (tinfoil.config_data.getVar('BBPATH').split(':')
>                       + [scripts_path]):
>              pluginpath = os.path.join(path, 'lib', 'recipetool')
> @@ -100,8 +96,6 @@ def main():
>              ret = args.func(args)
>          except bb.BBHandledException:
>              ret = 1
> -    finally:
> -        tinfoil.shutdown()
>  
>      return ret
>  
> -- 
> 2.34.1
> 

> 
> -=-=-=-=-=-=-=-=-=-=-=-
> Links: You receive all messages sent to this group.
> View/Reply Online (#188797): https://lists.openembedded.org/g/openembedded-core/message/188797
> Mute This Topic: https://lists.openembedded.org/mt/101820642/3617179
> Group Owner: openembedded-core+owner@lists.openembedded.org
> Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [alexandre.belloni@bootlin.com]
> -=-=-=-=-=-=-=-=-=-=-=-
>
chris.laplante@agilent.com Oct. 8, 2023, 9:13 p.m. UTC | #2
Hi Alexandre,

>
> Thank you for your patches!
>
> Could you remember changing your git config for your next submission:
> https://docs.yo/
> ctoproject.org%2Fnext%2Fcontributor-guide%2Fsubmit-
> changes.html%23fixing-your-from-
> identity&data=05%7C01%7Cchris.laplante%40agilent.com%7Cd8e4bf9a3b674c
> 281b2408dbc841e009%7Ca9c0bc098b46420693512ba12fb4a5c0%7C0%7C0%7
> C638323957497350867%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwM
> DAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C
> &sdata=edAZCGs8naAEfH%2FqL1IkJZ1xnUtaTzKd9OM28HHNeeg%3D&reserve
> d=0
>
> Thanks!

Ah, my mistake, sorry! I will fix it right now.

Thanks,
Chris
diff mbox series

Patch

diff --git a/scripts/recipetool b/scripts/recipetool
index e2d585d2c5..9eaecfbde6 100755
--- a/scripts/recipetool
+++ b/scripts/recipetool
@@ -22,13 +22,6 @@  logger = scriptutils.logger_create('recipetool')
 
 plugins = []
 
-def tinfoil_init(parserecipes):
-    import bb.tinfoil
-    import logging
-    tinfoil = bb.tinfoil.Tinfoil(tracking=True)
-    tinfoil.logger.setLevel(logger.getEffectiveLevel())
-    tinfoil.prepare(not parserecipes)
-    return tinfoil
 
 def main():
 
@@ -67,8 +60,11 @@  def main():
 
     scriptutils.logger_setup_color(logger, global_args.color)
 
-    tinfoil = tinfoil_init(False)
-    try:
+    import bb.tinfoil
+    with bb.tinfoil.Tinfoil(tracking=True) as tinfoil:
+        tinfoil.logger.setLevel(logger.getEffectiveLevel())
+        tinfoil.prepare(True)
+
         for path in (tinfoil.config_data.getVar('BBPATH').split(':')
                      + [scripts_path]):
             pluginpath = os.path.join(path, 'lib', 'recipetool')
@@ -100,8 +96,6 @@  def main():
             ret = args.func(args)
         except bb.BBHandledException:
             ret = 1
-    finally:
-        tinfoil.shutdown()
 
     return ret