If your code is several years old, it may have been written before the new “search api” was released.
You can now query using the “search” endpoint
Search tasks in a workspace – Asana
But, you will need to change your code a little bit, because the results are not paginated like it was in the previous endpoint (using offset), but they are sorted by date.
You can look at this thread I think for a sample call.
Python client library: using the Search API - Developers & API - Asana Community Forum