# Any Python experts here? Formerly working code now fails

**URL:** <https://boards.straightdope.com/t/any-python-experts-here-formerly-working-code-now-fails/855851>\
**Category:** Factual Questions\
**Created:** [June 17, 2020, 3:47pm UTC](https://boards.straightdope.com/t/any-python-experts-here-formerly-working-code-now-fails/855851 "2020-06-17T15:47:04Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![beowulff](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/beowulff/32/542_2.png) [@beowulff](https://boards.straightdope.com/u/beowulff)\
**Post date:** [June 17, 2020, 3:47pm UTC](https://boards.straightdope.com/t/any-python-experts-here-formerly-working-code-now-fails/855851/1 "2020-06-17T15:47:04Z")

</div>

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](https://github.com/JemRF/Blynk/blob/master/nonBlockingBlynk.py)

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?

---

<div class="post-metadata">

**Author:** ![SoToasty](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/sotoasty/32/2803_2.png) [@SoToasty](https://boards.straightdope.com/u/SoToasty)\
**Post date:** [June 17, 2020, 4:03pm UTC](https://boards.straightdope.com/t/any-python-experts-here-formerly-working-code-now-fails/855851/2 "2020-06-17T16:03:57Z")

</div>

Just checked git hub.

> <https://github.com/youngsoul/BlynkLib/blob/master/BlynkLib.py>

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

---

<div class="post-metadata">

**Author:** ![beowulff](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/beowulff/32/542_2.png) [@beowulff](https://boards.straightdope.com/u/beowulff)\
**Post date:** [June 17, 2020, 4:49pm UTC](https://boards.straightdope.com/t/any-python-experts-here-formerly-working-code-now-fails/855851/3 "2020-06-17T16:49:11Z")

</div>

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’

---

<div class="post-metadata">

**Author:** ![markn\_1](https://avatars.discourse-cdn.com/v4/letter/m/f9ae1b/32.png) [@markn\_1](https://boards.straightdope.com/u/markn_1)\
**Post date:** [June 17, 2020, 5:39pm UTC](https://boards.straightdope.com/t/any-python-experts-here-formerly-working-code-now-fails/855851/4 "2020-06-17T17:39:54Z")

</div>

Check the docs – add\_user\_task takes between 3 and 5 parameters.

---

<div class="post-metadata">

**Author:** ![sweepkick](https://avatars.discourse-cdn.com/v4/letter/s/87869e/32.png) [@sweepkick](https://boards.straightdope.com/u/sweepkick)\
**Post date:** [June 18, 2020, 3:40am UTC](https://boards.straightdope.com/t/any-python-experts-here-formerly-working-code-now-fails/855851/5 "2020-06-18T03:40:07Z")

</div>

I believe this is the official github repository:

> **[GitHub - vshymanskyy/blynk-library-python: Blynk library for Python. Works...](https://github.com/vshymanskyy/blynk-library-python)**
>
> Blynk library for Python. Works with Python 2, Python 3, MicroPython. - GitHub - vshymanskyy/blynk-library-python: Blynk library for Python. Works with Python 2, Python 3, MicroPython.

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:

> **[blynk-library-python/examples at master · vshymanskyy/blynk-library-python](https://github.com/vshymanskyy/blynk-library-python/tree/master/examples)**
>
> master/examples

---

<div class="post-metadata">

**Author:** ![pulykamell](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/pulykamell/32/3166_2.png) [@pulykamell](https://boards.straightdope.com/u/pulykamell)\
**Post date:** [June 18, 2020, 3:51am UTC](https://boards.straightdope.com/t/any-python-experts-here-formerly-working-code-now-fails/855851/6 "2020-06-18T03:51:49Z")

</div>

> [@markn\_1](#):
>
> Check the docs – add\_user\_task takes between 3 and 5 parameters.

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?

---

<div class="post-metadata">

**Author:** ![beowulff](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/beowulff/32/542_2.png) [@beowulff](https://boards.straightdope.com/u/beowulff)\
**Post date:** [June 18, 2020, 3:56am UTC](https://boards.straightdope.com/t/any-python-experts-here-formerly-working-code-now-fails/855851/7 "2020-06-18T03:56:27Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Si\_Amigo](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/si_amigo/32/2877_2.png) [@Si\_Amigo](https://boards.straightdope.com/u/Si_Amigo)\
**Post date:** [June 22, 2020, 4:24pm UTC](https://boards.straightdope.com/t/any-python-experts-here-formerly-working-code-now-fails/855851/8 "2020-06-22T16:24:47Z")

</div>

I think she’s dead. **🇬🇧**

---

<div class="post-metadata">

**Author:** ![Blue\_Blistering\_Barnacle](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/blue_blistering_barnacle/32/3386_2.png) [@Blue\_Blistering\_Barnacle](https://boards.straightdope.com/u/Blue_Blistering_Barnacle)\
**Post date:** [June 22, 2020, 8:11pm UTC](https://boards.straightdope.com/t/any-python-experts-here-formerly-working-code-now-fails/855851/9 "2020-06-22T20:11:25Z")

</div>

nm. nm.

---

<div class="post-metadata">

**Author:** ![commasense](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/commasense/32/3017_2.png) [@commasense](https://boards.straightdope.com/u/commasense)\
**Post date:** [June 24, 2020, 11:08pm UTC](https://boards.straightdope.com/t/any-python-experts-here-formerly-working-code-now-fails/855851/10 "2020-06-24T23:08:46Z")

</div>

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

“Is this the right room for an argument?”

---

<div class="post-metadata">

**Author:** ![Elendil\_s\_Heir](https://avatars.discourse-cdn.com/v4/letter/e/7cd45c/32.png) [@Elendil\_s\_Heir](https://boards.straightdope.com/u/Elendil_s_Heir)\
**Post date:** [June 25, 2020, 2:08pm UTC](https://boards.straightdope.com/t/any-python-experts-here-formerly-working-code-now-fails/855851/11 "2020-06-25T14:08:24Z")

</div>

> [@Si\_Amigo](#):
>
> I think she’s dead. **🇬🇧**

No, I’m not!

:: cacophony of violence and royal screeching resumes ::

---

<div class="post-metadata">

**Author:** ![Gary\_Robson](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/gary_robson/32/3448_2.png) [@Gary\_Robson](https://boards.straightdope.com/u/Gary_Robson)\
**Post date:** [June 26, 2020, 4:50pm UTC](https://boards.straightdope.com/t/any-python-experts-here-formerly-working-code-now-fails/855851/12 "2020-06-26T16:50:58Z")

</div>

> [@commasense](#):
>
> “Is this the right room for an argument?”

I’ve told you once!

_(somebody had to take the bait)_

---

<div class="post-metadata">

**Author:** ![beowulff](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/beowulff/32/542_2.png) [@beowulff](https://boards.straightdope.com/u/beowulff)\
**Post date:** [June 26, 2020, 4:53pm UTC](https://boards.straightdope.com/t/any-python-experts-here-formerly-working-code-now-fails/855851/13 "2020-06-26T16:53:34Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![commasense](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/commasense/32/3017_2.png) [@commasense](https://boards.straightdope.com/u/commasense)\
**Post date:** [June 27, 2020, 3:38am UTC](https://boards.straightdope.com/t/any-python-experts-here-formerly-working-code-now-fails/855851/14 "2020-06-27T03:38:38Z")

</div>

What took you so long?

---

<div class="post-metadata">

**Author:** ![commasense](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/commasense/32/3017_2.png) [@commasense](https://boards.straightdope.com/u/commasense)\
**Post date:** [June 27, 2020, 3:42am UTC](https://boards.straightdope.com/t/any-python-experts-here-formerly-working-code-now-fails/855851/15 "2020-06-27T03:42:04Z")

</div>

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!

---

<div class="post-metadata">

**Author:** ![Elendil\_s\_Heir](https://avatars.discourse-cdn.com/v4/letter/e/7cd45c/32.png) [@Elendil\_s\_Heir](https://boards.straightdope.com/u/Elendil_s_Heir)\
**Post date:** [June 27, 2020, 4:41am UTC](https://boards.straightdope.com/t/any-python-experts-here-formerly-working-code-now-fails/855851/16 "2020-06-27T04:41:11Z")

</div>

You’e a loony.

---

<div class="post-metadata">

**Author:** ![Gary\_Robson](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/gary_robson/32/3448_2.png) [@Gary\_Robson](https://boards.straightdope.com/u/Gary_Robson)\
**Post date:** [June 27, 2020, 7:28pm UTC](https://boards.straightdope.com/t/any-python-experts-here-formerly-working-code-now-fails/855851/17 "2020-06-27T19:28:50Z")

</div>

> [@commasense](#):
>
> What took you so long?

Hey, I argue at my own pace!

---

<div class="post-metadata">

**Author:** ![Elendil\_s\_Heir](https://avatars.discourse-cdn.com/v4/letter/e/7cd45c/32.png) [@Elendil\_s\_Heir](https://boards.straightdope.com/u/Elendil_s_Heir)\
**Post date:** [July 1, 2020, 5:43pm UTC](https://boards.straightdope.com/t/any-python-experts-here-formerly-working-code-now-fails/855851/18 "2020-07-01T17:43:11Z")

</div>

You could even argue in your spare time.

---

<div class="post-metadata">

**Author:** ![Dorjan](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/dorjan/32/12440_2.png) [@Dorjan](https://boards.straightdope.com/u/Dorjan)\
**Post date:** [July 8, 2020, 2:18pm UTC](https://boards.straightdope.com/t/any-python-experts-here-formerly-working-code-now-fails/855851/19 "2020-07-08T14:18:12Z")

</div>

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

> **[blynk-library-python/examples at master · vshymanskyy/blynk-library-python](https://github.com/vshymanskyy/blynk-library-python/tree/master/examples)**
>
> master/examples

---

<div class="post-metadata">

**Author:** ![kaylasdad99](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/kaylasdad99/32/3398_2.png) [@kaylasdad99](https://boards.straightdope.com/u/kaylasdad99)\
**Post date:** [July 8, 2020, 4:55pm UTC](https://boards.straightdope.com/t/any-python-experts-here-formerly-working-code-now-fails/855851/20 "2020-07-08T16:55:01Z")

</div>

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](https://boards.straightdope.com/t/any-python-experts-here-formerly-working-code-now-fails/855851)

No, it doesn’t.

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