[Bug]: client.get_requester() doesn't always work
scratchattach version
2.1.13
What happened?
Sometimes when calling client.get_requester() it returns None.
It seems that this is because in load_log_data of CloudActivity the matching list doesn't find any matches because the timestamp doesn't account for the time it takes to fetch the cloud logs.
Your code.
@client.request
def example():
return client.get_requester()
Traceback
none
have you actually experienced this?
have you actually experienced this?
Yes, I have been experiencing this. I had to edit the scratchattach package code to make a workaround so I can use scratchattach.
could you give your source code
My code is just the example code with a different function name. Here's an example from my code:
@client.request
def ping():
print("Ping request from", client.get_requester())
return "pong"
If you want all of my code:
Code
import scratchattach as sa
import warnings
warnings.filterwarnings('ignore', category=sa.LoginDataWarning)
session = sa.login_by_id([REDACTED])
conn = session.connect_cloud([REDACTED])
client = conn.requests()
@client.request
def ping():
print("Ping request from", client.get_requester())
return "pong"
@client.request
def save_level(id, level_data):
user = client.get_requester()
if not user:
return "500"
print(user, "is saving the level with id", id)
return level_data
@client.event
def on_ready():
print("Request handler is running")
client.start()
And you have tried this in isolation? It would be good to have more context as this doesn't happen normally. I personally have a server where this hasn't ever happened to my knowledge.
Your code raises a SyntaxError. Your problem might be caused because of the server you are using, have you tried this on your own PC?
Your code raises a SyntaxError. Your problem might be caused because of the server you are using, have you tried this on your own PC?
It raises a SyntaxError because I redacted my session id and project. I've been running it on my computer the whole time.
And you have tried this in isolation? It would be good to have more context as this doesn't happen normally. I personally have a server where this hasn't ever happened to my knowledge.
It seems to come and go. Sometimes it works, sometimes it doesn't.
I'm going to test a bit more and see if I can make it more reproducible.
This happens quite a bit with my project where it will return the default balance to the user as it thinks the username is "none" this has been present since 1.4.7 or before as it is in the first 25 users saved in my project.
It may be possible to create a drop-in replacement for client.get_requester if we can add an option to pass in an optional keyword-only argument called event which could contain data like the timestamp, the set value, etc