Kara-Moon Forum
October 31, 2024, 11:44:49 PM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News: You can go back to the main site here: Kara-Moon site
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: Crash while removing items from groove library  (Read 4035 times)
sciurius
Sr. Member
****
Posts: 443



« on: April 20, 2020, 12:35:03 PM »

This seems to be a python3 thingy:

Code:
     Processing library directory '/home/jv/lib/mma/grooves/zoom'.
       Deleting: /home/jv/lib/mma/grooves/zoom/rock.mma
Traceback (most recent call last):
  File "/home/jv/bin/mma", line 84, in <module>
    import MMA.main
  File "/home/jv/src/mma/MMA/main.py", line 102, in <module>
    MMA.auto.libUpdate()                # update and EXIT
  File "/home/jv/src/mma/MMA/auto.py", line 162, in libUpdate
    for f in db.keys():
RuntimeError: dictionary changed size during iteration

Suggested fix (seems to work for python2 as well):

Code:
*** auto.py~	2020-03-27 10:04:06.209477735 +0100
--- auto.py 2020-04-20 14:33:24.189912104 +0200
***************
*** 159,165 ****
          # Strip out defs of deleted (not found) files. Only on -g (update mode)
 
          if gbl.makeGrvDefs == 1:
!             for f in db.keys():
                  if f not in processedFiles:
                      print("       Deleting: %s" % f)
                      del db[f]
--- 159,165 ----
          # Strip out defs of deleted (not found) files. Only on -g (update mode)
 
          if gbl.makeGrvDefs == 1:
!             for f in list(db.keys()):
                  if f not in processedFiles:
                      print("       Deleting: %s" % f)
                      del db[f]
Logged
bvdp
Kara-Moon Master
****
Posts: 1449


WWW
« Reply #1 on: April 20, 2020, 04:19:07 PM »

Opps ... bad.

I see what is happening. using del() should be avoided in all but the most simple situations. I _think_ the better solution would simply be to recreate the list since list creating is fast and the entire process is not used all that often. I'll give it some work later today. Thanks for tracing this down!
Logged

My online life: http://www.mellowood.ca
sciurius
Sr. Member
****
Posts: 443



« Reply #2 on: April 20, 2020, 06:38:22 PM »

The solution I included is the generally accepted idiom for removing entries from a dict while iterating.
Logged
bvdp
Kara-Moon Master
****
Posts: 1449


WWW
« Reply #3 on: April 20, 2020, 08:55:58 PM »

The solution I included is the generally accepted idiom for removing entries from a dict while iterating.

Right you are. I actually just spent some time this PM looking at this. I have to assume that py2 was creating the list by itself and py3 is a but more needy. Whatever, it seems to work just fine! Thanks.

I will go over the code this week and verify that the other instances of del work in py3.
Logged

My online life: http://www.mellowood.ca
bvdp
Kara-Moon Master
****
Posts: 1449


WWW
« Reply #4 on: April 23, 2020, 06:37:15 PM »

The same bug appears in midi.py at line 475. This is in the end sync code (-1 command line option). Fix is the same. I'll put up a new devel version later today.

Logged

My online life: http://www.mellowood.ca
sciurius
Sr. Member
****
Posts: 443



« Reply #5 on: April 23, 2020, 06:50:39 PM »


     / )
    / /
__/' (_____
......... ((__)
..... _ ((___)
....... -'((__)
--.___((_)
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.21 | SMF © 2015, Simple Machines Valid XHTML 1.0! Valid CSS!
Page created in 0.042 seconds with 20 queries.