Skip to content

Python RTMClient Causes 100% CPU #569

@KIM-DONGWON

Description

@KIM-DONGWON

Description

Describe your issue here.

What type of issue is this? (place an x in one of the [ ])

  • bug
  • enhancement (feature request)
  • question
  • documentation related
  • testing related
  • discussion

Requirements (place an x in each of the [ ])

  • I've read and understood the Contributing guidelines and have done my best effort to follow them.
  • I've read and agree to the Code of Conduct.
  • I've searched for any related issues and avoided creating a duplicate issue.

Bug Report

Filling out the following details about bugs will help us solve your issue sooner.

Reproducible in:

slackclient version: 2.0.0

python version: 3.7

OS version(s): Centos in Docker

I am developing a Slack chatbot in Python
Acting as a Docker container

The problem is that the container suddenly takes 100% of the CPU
CPU doesn't grow slowly, suddenly takes 100%
The same thing happens if you delete everything in slack_translate

In fact, the issue occurs even if you are running python without doing anything in the slack workspace.

Please advise if you have any problems

Here is my source

import os
import time
import slack

project_name = os.environ['project_name']
source = os.environ['source']
target = os.environ['target']
slack_api_token = os.environ['slack_api_token']
translation = os.environ['translation']
translation_token = os.environ['translation_token']
environment = os.environ['environment']

@slack.RTMClient.run_on(event='message')
def slack_translate(**payload):

    event = payload['data']
    if 'subtype' not in event:

        channel_id = event['channel']
        thread_ts = event['event_ts']
        user = event['user']
        webclient = payload['web_client']
        message = event['text']
        
        webclient.chat_postMessage(
            channel=channel_id,
            text=message
        )
        time.sleep(0.5)

if __name__ == "__main__":    
    rtm_client = slack.RTMClient(token=slack_api_token)
    rtm_client.start() 

Here is Docker stats log

2019-11-25 21:50:01
CONTAINER ID        NAME                           CPU %               MEM USAGE / LIMIT     MEM %               NET I/O             BLOCK I/O           PIDS
c95fb2dcfe78        bot_test                       0.00%               24.25MiB / 7.638GiB   0.31%               7.4MB / 304kB       129MB / 38MB        5
0b98033669ce        docker_www_1                   0.01%               36.26MiB / 7.638GiB   0.46%               406kB / 908kB       41kB / 86.5kB       11
c753e1012f12        translateproject_translate_1   0.01%               98.81MiB / 7.638GiB   1.26%               12MB / 4.91MB       541kB / 0B          10
0b4c8f3ad089        mainback_db_1                  0.09%               224.4MiB / 7.638GiB   2.87%               4.27MB / 7.04MB     60.4MB / 128MB      34
da9bce2cb343        mainback_phpmyadmin_1          0.00%               66.26MiB / 7.638GiB   0.85%               3.2MB / 5.21MB      62.8MB / 438kB      11


2019-11-25 22:00:01
CONTAINER ID        NAME                           CPU %               MEM USAGE / LIMIT     MEM %               NET I/O             BLOCK I/O           PIDS
c95fb2dcfe78        bot_test                       0.00%               24.25MiB / 7.638GiB   0.31%               7.4MB / 308kB       129MB / 38MB        5
0b98033669ce        docker_www_1                   0.00%               36.26MiB / 7.638GiB   0.46%               406kB / 908kB       41kB / 86.5kB       11
c753e1012f12        translateproject_translate_1   0.00%               98.81MiB / 7.638GiB   1.26%               12MB / 4.91MB       541kB / 0B          10
0b4c8f3ad089        mainback_db_1                  0.10%               224.4MiB / 7.638GiB   2.87%               4.27MB / 7.04MB     60.4MB / 128MB      34
da9bce2cb343        mainback_phpmyadmin_1          0.00%               66.26MiB / 7.638GiB   0.85%               3.2MB / 5.21MB      62.8MB / 438kB      11


2019-11-25 22:10:01
CONTAINER ID        NAME                           CPU %               MEM USAGE / LIMIT     MEM %               NET I/O             BLOCK I/O           PIDS
c95fb2dcfe78        bot_test                       0.00%               24.25MiB / 7.638GiB   0.31%               7.41MB / 312kB      129MB / 38MB        5
0b98033669ce        docker_www_1                   0.00%               36.26MiB / 7.638GiB   0.46%               406kB / 908kB       41kB / 86.5kB       11
c753e1012f12        translateproject_translate_1   0.01%               98.81MiB / 7.638GiB   1.26%               12MB / 4.91MB       541kB / 0B          10
0b4c8f3ad089        mainback_db_1                  0.09%               224.4MiB / 7.638GiB   2.87%               4.27MB / 7.04MB     60.4MB / 128MB      34
da9bce2cb343        mainback_phpmyadmin_1          0.01%               66.26MiB / 7.638GiB   0.85%               3.2MB / 5.21MB      62.8MB / 438kB      11


2019-11-25 22:20:01
CONTAINER ID        NAME                           CPU %               MEM USAGE / LIMIT     MEM %               NET I/O             BLOCK I/O           PIDS
c95fb2dcfe78        bot_test                       101.85%             24.25MiB / 7.638GiB   0.31%               7.41MB / 312kB      129MB / 38MB        5
0b98033669ce        docker_www_1                   0.00%               36.26MiB / 7.638GiB   0.46%               406kB / 908kB       41kB / 86.5kB       11
c753e1012f12        translateproject_translate_1   0.00%               98.81MiB / 7.638GiB   1.26%               12MB / 4.91MB       541kB / 0B          10
0b4c8f3ad089        mainback_db_1                  0.10%               224.4MiB / 7.638GiB   2.87%               4.27MB / 7.04MB     60.4MB / 128MB      34
da9bce2cb343        mainback_phpmyadmin_1          0.00%               66.26MiB / 7.638GiB   0.85%               3.2MB / 5.21MB      62.8MB / 438kB      11

Metadata

Metadata

Assignees

No one assigned

    Labels

    Version: 2xarea:concurrencyIssues and PRs related to concurrencybugM-T: A confirmed bug report. Issues are confirmed when the reproduction steps are documentedrtm-client

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions