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

[v2, multi] remove from __main__ import ... statements #1956

Merged
merged 1 commit into from
Dec 16, 2018

Conversation

calebj
Copy link
Member

@calebj calebj commented Jul 24, 2018

Type

  • Bugfix

Description of the changes

Removed problematic from __main__ import ... statements from core cogs and checks.py.

red.py and all applicable core cogs have been refactored to function without any reference to __main__. Cogs which rely on importing user_allowed, send_cmd_help, set_cog or settings from __main__ will still continue to function.

Rationale

The from __main__ import in checks.py causes issues with ProcessPoolExecutors configured to use the spawn start method, which is the only option on Windows since fork is only present on UNIX.

Because the spawned child processes are sent a pickled representation of the cog's module as a part of their task(s), the child process must re-execute the cog's module before the task can be invoked. Because the spawned processes don't have red.py as their base module, __main__ is undefined, and the top-level import of cogs.utils.checks fails.

calebj added a commit to calebj/calebj-cogs that referenced this pull request Jul 24, 2018
Closes #62. Also threw in some new stuff, speedups and sanity checks:
- docs (seriously I think I need some help with these)
- check all filters in one call to the executor
- don't check individual messages in multi-message filters
- subgroup support for blacklist mode filters
- act upon white-mode non-matches when no black-mode filters apply (d'oh!)
- continue checking blacklist filters upon a white match
- handle 'inherit' argument correctly on asciify and priv-exempt
- read past newlines when setting pattern
- copy new feature parameters when copying a filter
- remove typing.Type annotation because Python <3.5.2 don't have it
- use ThreadPoolExecutor on Windows because of an upstream Red issue
  - ProcessPoolExecutor doesn't get along with `from __main__ import ...`
  - See Cog-Creators/Red-DiscordBot#1956
calebj added a commit to calebj/calebj-cogs that referenced this pull request Jul 24, 2018
Closes #62. Also threw in some new stuff, speedups and sanity checks:
- add command layout to docs (seriously I think I need some help with these)
- add enable and disable commands (hidden to not clutter the help list)
- check all filters in one call to the executor
- don't check individual messages in multi-message filters
- subgroup support for blacklist mode filters
- act upon white-mode non-matches when no black-mode filters apply (d'oh!)
- continue checking blacklist filters upon a white match
- handle 'inherit' argument correctly on asciify and priv-exempt
- read past newlines when setting pattern
- copy new feature parameters when copying a filter
- remove typing.Type annotation because Python <3.5.2 don't have it
- use ThreadPoolExecutor on Windows because of an upstream Red issue
  - ProcessPoolExecutor doesn't get along with `from __main__ import ...`
  - See Cog-Creators/Red-DiscordBot#1956
calebj added a commit to calebj/calebj-cogs that referenced this pull request Jul 24, 2018
Closes #62. Also threw in some new stuff, speedups and sanity checks:
- add command layout to docs (seriously I think I need some help with these)
- add enable and disable commands (hidden to not clutter the help list)
- check all filters in one call to the executor
- don't check individual messages in multi-message filters
- subgroup support for blacklist mode filters
- act upon white-mode non-matches when no black-mode filters apply (d'oh!)
- continue checking blacklist filters upon a white match
- handle 'inherit' argument correctly on asciify and priv-exempt
- read past newlines when setting pattern
- copy new feature parameters when copying a filter
- remove typing.Type annotation because Python <3.5.2 don't have it
- use ThreadPoolExecutor on Windows because of an upstream Red issue
  - ProcessPoolExecutor doesn't get along with `from __main__ import ...`
  - See Cog-Creators/Red-DiscordBot#1956
calebj added a commit to calebj/calebj-cogs that referenced this pull request Jul 24, 2018
Closes #62. Also threw in some new stuff, speedups and sanity checks:
- add command layout to docs (seriously I think I need some help with these)
- add enable and disable commands (hidden to not clutter the help list)
- check all filters in one call to the executor
- don't check individual messages in multi-message filters
- subgroup support for blacklist mode filters
- act upon white-mode non-matches when no black-mode filters apply (d'oh!)
- continue checking blacklist filters upon a white match
- handle 'inherit' argument correctly on asciify and priv-exempt
- read past newlines when setting pattern
- copy new feature parameters when copying a filter
- remove typing.Type annotation because Python <3.5.2 don't have it
- use ThreadPoolExecutor on Windows because of an upstream Red issue
  - ProcessPoolExecutor doesn't get along with `from __main__ import ...`
  - See Cog-Creators/Red-DiscordBot#1956
@calebj
Copy link
Member Author

calebj commented Jul 29, 2018

Bump!

@Redjumpman Redjumpman added the V2 label Aug 12, 2018
@Tobotimus Tobotimus added QA: Passed Used by few QA members. Has been approved by the assigned QA member(s). and removed QA: Unassigned labels Aug 17, 2018
@Tobotimus Tobotimus merged commit a42c4fb into Cog-Creators:develop Dec 16, 2018
@calebj calebj deleted the remove_from_main_import branch December 16, 2018 23:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
QA: Passed Used by few QA members. Has been approved by the assigned QA member(s).
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants