Any Python experts here? Formerly working code now fails

I had to upgrade and re-install the OS on one of my Raspberry Pi’s. A script that I wrote now fails, and when I tried this example code (which i used as the basis for my Blynk control code), it fails with the same error.

Example is here: Blynk/nonBlockingBlynk.py at master · JemRF/Blynk · GitHub

When I run it, I get the following message:

File “blynk_python_non_blocking.py”, line 19, in BlynkLoop
blynk.set_user_task(my_user_task, 1000)
AttributeError: Blynk instance has no attribute ‘set_user_task’

Any ideas on how to fix this?

Just checked git hub.

Looks like they have removed the set_user_task function and you are supposed to use add_user_task.

Haven’t looked at any code but it might just be change the name to see if it works

I had high hopes, but - no such luck:

blynk.add_user_task(my_user_task, 1000)

AttributeError: Blynk instance has no attribute ‘add_user_task’

Check the docs – add_user_task takes between 3 and 5 parameters.

I believe this is the official github repository:

Looks like set_user_task was removed in February 2019.

There are some example here that might point you in the right direction for how to modify your code to work with the latest version:

I only see 2 that need to be specified: task, and second_period. You don’t have to explicitly pass “self” (it’s bound to the instance) and there are defaults for initial_state and authenticated.

Can you just check the BlinkLib.py file you have to make sure you do have either add_user_task or set_user_task defined in there?

Thanks for all the help, but I finally gave up on that example.
I don’t need to have Blynk running periodic tasks, so I just put Blynk.run() in a thread with a sleep time of 1 second, and that worked.

I think she’s dead. :uk:

nm. nm.

There are tons of Python experts here. I’ll prove it.

“Is this the right room for an argument?”

No, I’m not!

:: cacophony of violence and royal screeching resumes ::

I’ve told you once!

(somebody had to take the bait)

You want to complain?
Look at this message board! Only had it for a week…

What took you so long?

I’m going to blame the switch to the new platform for the dispiriting lack of appropriate responses to my brilliant setup. I expect much better performance next time someone quotes Monty Python. C’mon people! Get it together!

You’e a loony.

Hey, I argue at my own pace!

You could even argue in your spare time.

Looks like you got it working for you, but timer.py is what replaced that function. See here:

Well, I wouldn’t exactly call myself a Python EXPERT, per se, but wrt the thread title:

Any Python experts here? Formerly working code now fails

No, it doesn’t.

ETA: I see I’ve been ninja’d.