Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Long time loading on_ready(): and don't see all members of guild. #4011

Closed
Rexikon opened this issue Apr 17, 2020 · 5 comments
Closed

Long time loading on_ready(): and don't see all members of guild. #4011

Rexikon opened this issue Apr 17, 2020 · 5 comments
Labels
selfbot Self-bot related issue wontfix This will not be worked on.

Comments

@Rexikon
Copy link

Rexikon commented Apr 17, 2020

Summary

Got simple code and it takes about 92 seconds to load.
Probably it stuck at async def on_ready():
Additionality it doesn't print all members of guild.

Reproduction Steps

import discord
import logging
import time

logger = logging.getLogger('discord')
logger.setLevel(logging.DEBUG)
handler = logging.FileHandler(filename='debug.log', encoding='utf-8', mode='w')
handler.setFormatter(logging.Formatter('%(asctime)s:%(levelname)s:%(name)s: %(message)s'))
logger.addHandler(handler)
overall_start = time.time()
start = time.time()
client = discord.AutoShardedClient()
@client.event
async def on_ready():
    global start
    end = time.time()
    print('We have logged in as {0.user}'.format(client))
    print('Logged in time: {}'.format(end-start))
    start = time.time()
    guild = client.get_guild(guildID)
    end = time.time()
    print('guilds get time: {}'.format(end-start))
    for m in guild.members:
        print(f'Guild: {guild.name} Member_Name: {m}')
    print("END")
    await client.close()
client.run('token', bot=False)
overall_end = time.time()
print('Overall time: {}'.format(overall_end-overall_start))

Actual Results

We have logged in as XXXX
Logged in time: 93.21575331687927
guilds get time: 3.0994415283203125e-06
Guild: XXXX Member_Name: Rexikon
Guild: XXXX Member_Name: XXXX
Guild: XXXX Member_Name: XXX
END
Overall time: 93.38851141929626

Checklist

  • [ X] I have searched the open issues for duplicates.
  • [X ] I have shown the entire traceback, if possible.
  • [X ] I have removed my token from display, if visible.

System Information

@Rexikon
Copy link
Author

Rexikon commented Apr 17, 2020

debug log (replaced sensitive data with XXX):

2020-04-17 15:39:57,353:DEBUG:discord.client: on_ready has successfully been registered as an event
2020-04-17 15:39:57,353:INFO:discord.client: logging in using static token
2020-04-17 15:39:57,666:DEBUG:discord.http: GET https://discordapp.com/api/v7/users/@me with None has returned 200
2020-04-17 15:39:57,666:DEBUG:discord.http: GET https://discordapp.com/api/v7/users/@me has received {'id': 'XXX', 'username': 'XXX', 'avatar': None, 'discriminator': 'XXX', 'public_flags': 0, 'flags': 0, 'email': 'XXX', 'verified': True, 'locale': 'en-US', 'nsfw_allowed': None, 'mfa_enabled': False, 'phone': '+XXX'}
2020-04-17 15:39:57,846:DEBUG:discord.http: GET https://discordapp.com/api/v7/gateway/bot with None has returned 200
2020-04-17 15:39:57,846:DEBUG:discord.http: GET https://discordapp.com/api/v7/gateway/bot has received {'url': 'wss://gateway.discord.gg', 'shards': 1, 'session_start_limit': {'total': 1000, 'remaining': 1000, 'reset_after': 0}}
2020-04-17 15:39:58,284:DEBUG:discord.client: Dispatching event socket_raw_receive
2020-04-17 15:39:58,284:DEBUG:discord.gateway: For Shard ID 0: WebSocket Event: {'t': None, 's': None, 'op': 10, 'd': {'heartbeat_interval': 41250, '_trace': ['["gateway-prd-main-95sm",{"micros":0.0}]']}}
2020-04-17 15:39:58,284:DEBUG:discord.client: Dispatching event socket_response
2020-04-17 15:39:58,285:DEBUG:discord.client: Dispatching event socket_raw_send
2020-04-17 15:39:58,285:DEBUG:discord.client: Dispatching event socket_raw_send
2020-04-17 15:39:58,285:INFO:discord.gateway: Shard ID 0 has sent the IDENTIFY payload.
2020-04-17 15:39:58,457:DEBUG:discord.client: Dispatching event socket_raw_receive
2020-04-17 15:39:58,457:DEBUG:discord.gateway: For Shard ID 0: WebSocket Event: {'t': None, 's': None, 'op': 11, 'd': None}
2020-04-17 15:39:58,457:DEBUG:discord.client: Dispatching event socket_response
2020-04-17 15:39:58,539:DEBUG:discord.client: Dispatching event socket_raw_receive
2020-04-17 15:39:58,540:DEBUG:discord.gateway: For Shard ID 0: WebSocket Event: {XXX}
2020-04-17 15:39:58,542:DEBUG:discord.client: Dispatching event socket_response
2020-04-17 15:39:58,542:INFO:discord.gateway: Shard ID 0 has connected to Gateway: ["gateway-prd-main-95sm",{"micros":40009,"calls":["discord-sessions-prd-1-9",{"micros":35292,"calls":["start_session",{"micros":32437,"calls":["api-prd-main-7tks",{"micros":27770,"calls":["get_user",{"micros":3599},"add_authorized_ip",{"micros":2966},"get_guilds",{"micros":1836},"private_channels",{"micros":6148},"read_states",{"micros":659},"coros_wait",{"micros":123},"aliases",{"micros":808},"affine_user_ids",{"micros":605},"experiments",{"micros":2252}]}]},"guilds_connect",{"micros":1595,"calls":[]},"presence_connect",{"micros":1,"calls":[]}]}]}] (Session ID: XXX).
2020-04-17 15:39:58,543:DEBUG:discord.client: Dispatching event connect
2020-04-17 15:39:58,543:DEBUG:discord.client: Dispatching event socket_raw_receive
2020-04-17 15:39:58,543:DEBUG:discord.gateway: For Shard ID 0: WebSocket Event: {'t': 'SESSIONS_REPLACE', 's': 2, 'op': 0, 'd': [{'status': 'online', 'session_id': 'XXX', 'client_info': {'version': 0, 'os': 'other', 'client': 'web'}, 'activities': []}]}
2020-04-17 15:39:58,543:DEBUG:discord.client: Dispatching event socket_response
2020-04-17 15:39:58,543:DEBUG:discord.gateway: Unknown event SESSIONS_REPLACE.
2020-04-17 15:40:00,544:DEBUG:discord.client: Dispatching event socket_raw_send
2020-04-17 15:40:39,535:DEBUG:discord.gateway: Keeping websocket alive with sequence 2.
2020-04-17 15:40:39,535:DEBUG:discord.client: Dispatching event socket_raw_send
2020-04-17 15:40:39,703:DEBUG:discord.client: Dispatching event socket_raw_receive
2020-04-17 15:40:39,703:DEBUG:discord.gateway: For Shard ID 0: WebSocket Event: {'t': None, 's': None, 'op': 11, 'd': None}
2020-04-17 15:40:39,703:DEBUG:discord.client: Dispatching event socket_response
2020-04-17 15:41:20,785:DEBUG:discord.gateway: Keeping websocket alive with sequence 2.
2020-04-17 15:41:20,786:DEBUG:discord.client: Dispatching event socket_raw_send
2020-04-17 15:41:20,935:DEBUG:discord.client: Dispatching event socket_raw_receive
2020-04-17 15:41:20,935:DEBUG:discord.gateway: For Shard ID 0: WebSocket Event: {'t': None, 's': None, 'op': 11, 'd': None}
2020-04-17 15:41:20,935:DEBUG:discord.client: Dispatching event socket_response
2020-04-17 15:41:30,554:INFO:discord.state: Somehow timed out waiting for chunks.
2020-04-17 15:41:30,554:DEBUG:discord.client: Dispatching event guild_available
2020-04-17 15:41:30,554:DEBUG:discord.client: Dispatching event shard_ready
2020-04-17 15:41:30,554:DEBUG:discord.client: Dispatching event ready
2020-04-17 15:41:30,726:INFO:discord.gateway: Websocket closed with 1000 (), cannot reconnect.
2020-04-17 15:41:30,726:DEBUG:discord.client: Dispatching event disconnect
2020-04-17 15:41:30,726:INFO:discord.client: Cleaning up tasks.
2020-04-17 15:41:30,726:INFO:discord.client: Closing the event loop.

@skyblockz
Copy link

It might be your internet issues for the slow part, and for the missing members, if your internet is slow, it might have dropped some packets too

@Rexikon
Copy link
Author

Rexikon commented Apr 17, 2020

It might be your internet issues for the slow part, and for the missing members, if your internet is slow, it might have dropped some packets too

I have tested it at 4 different hosts. It isn't internet issue.

@Gobot1234
Copy link
Contributor

Can I suggest potentially reading this issue #2567?

@applebee1558
Copy link
Contributor

Are you doing this with a self-bot? I don’t remember sessions_replace being an event for bots. Another thing is I don’t think discord sends every guild member anymore for selfbots and instead use lazy-loading.

@Rapptz Rapptz added selfbot Self-bot related issue wontfix This will not be worked on. labels Feb 18, 2021
@Rapptz Rapptz closed this as completed Feb 18, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
selfbot Self-bot related issue wontfix This will not be worked on.
Projects
None yet
Development

No branches or pull requests

5 participants