Skip to content
Discussion options

You must be logged in to vote

Your background task is running into an error because you can not pass an integer to the write function:

>>> with open('example.txt', 'w') as f:
...     f.write(1)
...
Traceback (most recent call last):
  File "<stdin>", line 2, in <module>
TypeError: write() argument must be str, not int

You will have to convert your counter variable to a string when writing it to the file instead.

To see this sort of error you might want to wrap your code in a try except block to be able to log it, or you can base your code off of the other background task example using the tasks extension, as it will print/log errors by default.

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by ChristopheTdn
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants