Skip to contentSkip to conversation

prserv: remove dead code in exception handling

PATCH In review [email protected] 2 participants 3 messages Mar 6, 2024 – Mar 8, 2024

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 prserv: remove dead code in exception handling

From: Michael Opdenacker <[email protected]>

As explained in https://docs.python.org/3/reference/compound_stmts.html#else-clause,
the code after the "else" statement won't be run as there is a "return" in the "try" block.

---

See the whole code on
https://git.openembedded.org/bitbake/tree/lib/prserv/serv.py#n38

---
 lib/prserv/serv.py | 2 --
 1 file changed, 2 deletions(-)
lib/prserv/serv.py +0 -2
index 5fc8863f7..5032f7cd7 100644
@@ -40,8 +40,6 @@ class PRServerClient(bb.asyncrpc.AsyncServerConnection):
         except:
             self.table.sync()
             raise
-        else:
-            self.table.sync_if_dirty()
 
     async def handle_get_pr(self, request):
         version = request['version']
Signature · 1 line
2.34.1
#1 lore raw
Quoted 22 lines · Michael Opdenacker via lists.openembedded.org

From: Michael Opdenacker <[email protected]>

As explained in https://docs.python.org/3/reference/compound_stmts.html#else-clause,
the code after the "else" statement won't be run as there is a "return" in the "try" block.

---

See the whole code on
https://git.openembedded.org/bitbake/tree/lib/prserv/serv.py#n38

---
 lib/prserv/serv.py | 2 --
 1 file changed, 2 deletions(-)
lib/prserv/serv.py +0 -0
index 5fc8863f7..5032f7cd7 100644

lib/prserv/serv.py class PRServerClient(bb.asyncrpc.AsyncServerConnection): · line 44

Quoted 5 lines
lib/prserv/serv.py +0 -2
@@ -40,8 +40,6 @@ class PRServerClient(bb.asyncrpc.AsyncServerConnection):
         except:
             self.table.sync()
             raise
-        else:
-            self.table.sync_if_dirty()

It is correct this will not run, should self.table.sync() be in a finally block instead to make sure the DB is always synced? (the except can also be removed then)

Quoted 15 lines
lib/prserv/serv.py +0 -1
     async def handle_get_pr(self, request):
         version = request['version']
--

2.34.1

-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#15990): https://lists.openembedded.org/g/bitbake-devel/message/15990
Mute This Topic: https://lists.openembedded.org/mt/104770220/3616693
Group Owner: [email protected]
Unsubscribe: https://lists.openembedded.org/g/bitbake-devel/unsub [[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-

#2 lore raw

Hi Joshua

Quoted 19 lines · Joshua Watt
Quoted 16 lines · Michael Opdenacker via lists.openembedded.org

From: Michael Opdenacker <[email protected]>

As explained in https://docs.python.org/3/reference/compound_stmts.html#else-clause,
the code after the "else" statement won't be run as there is a "return" in the "try" block.

---

See the whole code on
https://git.openembedded.org/bitbake/tree/lib/prserv/serv.py#n38

---
  lib/prserv/serv.py | 2 --
  1 file changed, 2 deletions(-)
Quoted 13 lines

lib/prserv/serv.py class PRServerClient(bb.asyncrpc.AsyncServerConnection): · line 44

Quoted 10 lines
lib/prserv/serv.py +0 -2
index 5fc8863f7..5032f7cd7 100644
@@ -40,8 +40,6 @@ class PRServerClient(bb.asyncrpc.AsyncServerConnection):
          except:
              self.table.sync()
              raise
-        else:
-            self.table.sync_if_dirty()

It is correct this will not run, should self.table.sync() be in a finally block instead to make sure the DB is always synced? (the except can also be removed then)

I've implemented this simplification, but it would cause to run "self.table.sync()" even when no exception is caught. That wasn't the case before. Is that what you were suggesting?

Happy to submit my change if you agree!
Cheers
Michael.

Signature · 3 lines
Michael Opdenacker, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com