Skip to content

Commit 812de2b

Browse files
authored
Merge pull request CloudBotIRC#170 from linuxdaemon/gonzobot+fix-debug-mode-coros
Fix coroutine hooks erroring in asyncio debug mode
2 parents fa11fc1 + c9eae75 commit 812de2b

25 files changed

+76
-65
lines changed

.travis.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ python:
55
- "3.6"
66
- "3.7-dev"
77

8+
cache: pip
9+
810
install:
911
- "sudo apt-get update -q"
1012
- "sudo apt-get install -y python3-lxml libenchant-dev"
@@ -18,3 +20,4 @@ after_success:
1820

1921
env:
2022
- PYTHONPATH=.
23+
- PYTHONPATH=. PYTHONASYNCIODEBUG=1

plugins/admin_bot.py

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,17 @@
55
from cloudbot.util import formatting
66

77

8-
@asyncio.coroutine
98
@hook.command("groups", "listgroups", "permgroups", permissions=["permissions_users"], autohelp=False)
9+
@asyncio.coroutine
1010
def get_permission_groups(conn):
1111
"""- lists all valid groups
1212
:type conn: cloudbot.client.Client
1313
"""
1414
return "Valid groups: {}".format(conn.permissions.get_groups())
1515

1616

17-
@asyncio.coroutine
1817
@hook.command("gperms", permissions=["permissions_users"])
18+
@asyncio.coroutine
1919
def get_group_permissions(text, conn, notice):
2020
"""<group> - lists permissions given to <group>
2121
:type text: str
@@ -33,8 +33,8 @@ def get_group_permissions(text, conn, notice):
3333
notice("Unknown group '{}'".format(group))
3434

3535

36-
@asyncio.coroutine
3736
@hook.command("gusers", permissions=["permissions_users"])
37+
@asyncio.coroutine
3838
def get_group_users(text, conn, notice):
3939
"""<group> - lists users in <group>
4040
:type text: str
@@ -52,8 +52,8 @@ def get_group_users(text, conn, notice):
5252
notice("Unknown group '{}'".format(group))
5353

5454

55-
@asyncio.coroutine
5655
@hook.command("uperms", autohelp=False)
56+
@asyncio.coroutine
5757
def get_user_permissions(text, conn, mask, has_permission, notice):
5858
"""[user] - lists all permissions given to [user], or the caller if no user is specified
5959
:type text: str
@@ -77,8 +77,8 @@ def get_user_permissions(text, conn, mask, has_permission, notice):
7777
return "User {} has no elevated permissions".format(user)
7878

7979

80-
@asyncio.coroutine
8180
@hook.command("ugroups", autohelp=False)
81+
@asyncio.coroutine
8282
def get_user_groups(text, conn, mask, has_permission, notice):
8383
"""[user] - lists all permissions given to [user], or the caller if no user is specified
8484
:type text: str
@@ -102,8 +102,8 @@ def get_user_groups(text, conn, mask, has_permission, notice):
102102
return "User {} is in no permission groups".format(user)
103103

104104

105-
@asyncio.coroutine
106105
@hook.command("deluser", permissions=["permissions_users"])
106+
@asyncio.coroutine
107107
def remove_permission_user(text, nick, bot, conn, notice, reply, admin_log):
108108
"""<user> [group] - removes <user> from [group], or from all groups if no group is specified
109109
:type text: str
@@ -164,8 +164,8 @@ def remove_permission_user(text, nick, bot, conn, notice, reply, admin_log):
164164
permission_manager.reload()
165165

166166

167-
@asyncio.coroutine
168167
@hook.command("adduser", permissions=["permissions_users"])
168+
@asyncio.coroutine
169169
def add_permissions_user(text, nick, conn, bot, notice, reply, admin_log):
170170
"""<user> <group> - adds <user> to <group>
171171
:type text: str
@@ -208,8 +208,8 @@ def add_permissions_user(text, nick, conn, bot, notice, reply, admin_log):
208208
permission_manager.reload()
209209

210210

211-
@asyncio.coroutine
212211
@hook.command("stopthebot", permissions=["botcontrol"])
212+
@asyncio.coroutine
213213
def stop(text, bot):
214214
"""[reason] - stops me with [reason] as its quit message.
215215
:type text: str
@@ -221,8 +221,8 @@ def stop(text, bot):
221221
yield from bot.stop()
222222

223223

224-
@asyncio.coroutine
225224
@hook.command(permissions=["botcontrol"])
225+
@asyncio.coroutine
226226
def restart(text, bot):
227227
"""[reason] - restarts me with [reason] as its quit message.
228228
:type text: str
@@ -234,8 +234,8 @@ def restart(text, bot):
234234
yield from bot.restart()
235235

236236

237-
@asyncio.coroutine
238237
@hook.command(permissions=["botcontrol", "snoonetstaff"])
238+
@asyncio.coroutine
239239
def join(text, conn, nick, notice, admin_log):
240240
"""<channel> - joins <channel>
241241
:type text: str
@@ -249,8 +249,8 @@ def join(text, conn, nick, notice, admin_log):
249249
conn.join(target)
250250

251251

252-
@asyncio.coroutine
253252
@hook.command(permissions=["botcontrol", "snoonetstaff"], autohelp=False)
253+
@asyncio.coroutine
254254
def part(text, conn, nick, chan, notice, admin_log):
255255
"""[#channel] - parts [#channel], or the caller's channel if no channel is specified
256256
:type text: str
@@ -269,8 +269,8 @@ def part(text, conn, nick, chan, notice, admin_log):
269269
conn.part(target)
270270

271271

272-
@asyncio.coroutine
273272
@hook.command(autohelp=False, permissions=["botcontrol"])
273+
@asyncio.coroutine
274274
def cycle(text, conn, chan, notice):
275275
"""[#channel] - cycles [#channel], or the caller's channel if no channel is specified
276276
:type text: str
@@ -289,8 +289,8 @@ def cycle(text, conn, chan, notice):
289289
conn.join(target)
290290

291291

292-
@asyncio.coroutine
293292
@hook.command(permissions=["botcontrol"])
293+
@asyncio.coroutine
294294
def nick(text, conn, notice, is_nick_valid):
295295
"""<nick> - changes my nickname to <nick>
296296
:type text: str
@@ -304,8 +304,8 @@ def nick(text, conn, notice, is_nick_valid):
304304
conn.set_nick(text)
305305

306306

307-
@asyncio.coroutine
308307
@hook.command(permissions=["botcontrol"])
308+
@asyncio.coroutine
309309
def raw(text, conn, notice):
310310
"""<command> - sends <command> as a raw IRC command
311311
:type text: str
@@ -315,8 +315,8 @@ def raw(text, conn, notice):
315315
conn.send(text)
316316

317317

318-
@asyncio.coroutine
319318
@hook.command(permissions=["botcontrol", "snoonetstaff"])
319+
@asyncio.coroutine
320320
def say(text, conn, chan, nick, admin_log):
321321
"""[#channel] <message> - says <message> to [#channel], or to the caller's channel if no channel is specified
322322
:type text: str
@@ -335,8 +335,8 @@ def say(text, conn, chan, nick, admin_log):
335335
conn.message(channel, text)
336336

337337

338-
@asyncio.coroutine
339338
@hook.command("message", "sayto", permissions=["botcontrol", "snoonetstaff"])
339+
@asyncio.coroutine
340340
def message(text, conn, nick, admin_log):
341341
"""<name> <message> - says <message> to <name>
342342
:type text: str
@@ -349,8 +349,8 @@ def message(text, conn, nick, admin_log):
349349
conn.message(channel, text)
350350

351351

352-
@asyncio.coroutine
353352
@hook.command("me", "act", permissions=["botcontrol", "snoonetstaff"])
353+
@asyncio.coroutine
354354
def me(text, conn, chan, nick, admin_log):
355355
"""[#channel] <action> - acts out <action> in a [#channel], or in the current channel of none is specified
356356
:type text: str
@@ -369,8 +369,8 @@ def me(text, conn, chan, nick, admin_log):
369369
conn.ctcp(channel, "ACTION", text)
370370

371371

372-
@asyncio.coroutine
373372
@hook.command(autohelp=False, permissions=["botcontrol"])
373+
@asyncio.coroutine
374374
def listchans(conn, chan, message, notice):
375375
"""- Lists the current channels the bot is in"""
376376
chans = ', '.join(sorted(conn.channels, key=lambda x: x.strip('#').lower()))

plugins/autojoin.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ def load_cache(db):
3131
chan_cache[row['conn']].add(row['chan'])
3232

3333

34-
@asyncio.coroutine
3534
@hook.irc_raw('376')
35+
@asyncio.coroutine
3636
def do_joins(conn):
3737
join_throttle = conn.config.get("join_throttle", 0.4)
3838
for chan in chan_cache[conn.name]:

plugins/brainfuck.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111
MAX_STEPS = 1000000
1212

1313

14-
@asyncio.coroutine
1514
@hook.command("brainfuck", "bf")
15+
@asyncio.coroutine
1616
def bf(text):
1717
"""<prog> - executes <prog> as Brainfuck code
1818
:type text: str

plugins/chain.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,8 +130,8 @@ def wrap_event(_hook, event, cmd, args):
130130
return cmd_event
131131

132132

133-
@asyncio.coroutine
134133
@hook.command
134+
@asyncio.coroutine
135135
def chain(text, bot, event):
136136
"""<cmd1> [args...] | <cmd2> [args...] | ... - Runs commands in a chain, piping the output from previous commands to tne next"""
137137
cmds = parse_chain(text, bot)

plugins/core/cap.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,8 @@ def _launch_handler(subcmd, event, **kwargs):
7676
yield from async_util.run_func(event.loop, handler, *args)
7777

7878

79-
@asyncio.coroutine
8079
@_subcmd_handler("LS")
80+
@asyncio.coroutine
8181
def cap_ls(conn, caplist, event, irc_paramlist, bot, logger):
8282
logger.info("[%s|cap] Available capabilities: %s", conn.name, caplist)
8383
yield from handle_available_caps(conn, caplist, event, irc_paramlist, bot)
@@ -102,14 +102,14 @@ def handle_req_resp(enabled, conn, caplist, event, bot):
102102
cap_queue[cap].set_result(enabled)
103103

104104

105-
@asyncio.coroutine
106105
@_subcmd_handler("ACK")
106+
@asyncio.coroutine
107107
def cap_ack_nak(conn, caplist, event, bot):
108108
yield from handle_req_resp(True, conn, caplist, event, bot)
109109

110110

111-
@asyncio.coroutine
112111
@_subcmd_handler("NAK")
112+
@asyncio.coroutine
113113
def cap_nak(conn, caplist, event, bot):
114114
yield from handle_req_resp(False, conn, caplist, event, bot)
115115

@@ -119,8 +119,8 @@ def cap_list(logger, caplist, conn):
119119
logger.info("[%s|cap] Enabled Capabilities: %s", conn.name, caplist)
120120

121121

122-
@asyncio.coroutine
123122
@_subcmd_handler("NEW")
123+
@asyncio.coroutine
124124
def cap_new(logger, caplist, conn, event, bot, irc_paramlist):
125125
logger.info("[%s|cap] New capabilities advertised: %s", conn.name, caplist)
126126
yield from handle_available_caps(conn, caplist, event, irc_paramlist, bot)
@@ -135,8 +135,8 @@ def cap_del(logger, conn, caplist):
135135
server_caps[cap.name.casefold()] = False
136136

137137

138-
@asyncio.coroutine
139138
@hook.irc_raw("CAP")
139+
@asyncio.coroutine
140140
def on_cap(irc_paramlist, event):
141141
args = {}
142142
if len(irc_paramlist) > 2:

plugins/core/check_conn.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ def do_reconnect(conn):
3636
return "Reconnected to '{}'".format(conn.name)
3737

3838

39-
@asyncio.coroutine
4039
@hook.command(autohelp=False, permissions=["botcontrol"], singlethread=True)
40+
@asyncio.coroutine
4141
def reconnect(conn, text, bot):
4242
"""[connection] - Reconnects to [connection] or the current connection if not specified"""
4343
if not text:
@@ -83,9 +83,9 @@ def on_connect(conn):
8383
conn.memory["lag"] = 0
8484

8585

86-
@asyncio.coroutine
8786
@hook.command("lagcheck", autohelp=False, permissions=["botcontrol"])
8887
@hook.periodic(30)
88+
@asyncio.coroutine
8989
def lag_check(bot):
9090
now = time.time()
9191
for conn in bot.connections.values():

plugins/core/core_misc.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88

99

1010
# Auto-join on Invite (Configurable, defaults to True)
11-
@asyncio.coroutine
1211
@hook.irc_raw('INVITE')
12+
@asyncio.coroutine
1313
def invite(irc_paramlist, conn):
1414
"""
1515
:type irc_paramlist: list[str]
@@ -61,8 +61,8 @@ def on_mode_change(conn, irc_paramlist, message):
6161

6262

6363
# Identify to NickServ (or other service)
64-
@asyncio.coroutine
6564
@hook.irc_raw('004')
65+
@asyncio.coroutine
6666
def onjoin(conn, bot):
6767
"""
6868
:type conn: cloudbot.clients.clients.IrcClient
@@ -105,8 +105,8 @@ def onjoin(conn, bot):
105105
bot.logger.info("[{}|misc] Bot has finished sending join commands for network.".format(conn.name))
106106

107107

108-
@asyncio.coroutine
109108
@hook.irc_raw('376')
109+
@asyncio.coroutine
110110
def do_joins(logger, conn):
111111
chans = copy(conn.channels)
112112

@@ -118,8 +118,8 @@ def do_joins(logger, conn):
118118
yield from asyncio.sleep(join_throttle)
119119

120120

121-
@asyncio.coroutine
122121
@hook.irc_raw('004')
122+
@asyncio.coroutine
123123
def keep_alive(conn):
124124
"""
125125
:type conn: cloudbot.clients.clients.IrcClient
@@ -137,8 +137,8 @@ def on_nick_in_use(conn, irc_paramlist):
137137
conn.cmd("NICK", conn.nick)
138138

139139

140-
@asyncio.coroutine
141140
@hook.irc_raw('432', singlethread=True)
141+
@asyncio.coroutine
142142
def on_invalid_nick(conn):
143143
nick = conn.config['nick']
144144
conn.nick = nick

plugins/core/core_sieve.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ def task_clear(loop):
1818
loop.call_later(600, task_clear, loop)
1919

2020

21-
@asyncio.coroutine
2221
@hook.irc_raw('004')
22+
@asyncio.coroutine
2323
def init_tasks(loop, conn):
2424
global ready
2525
if ready:
@@ -31,8 +31,8 @@ def init_tasks(loop, conn):
3131
ready = True
3232

3333

34-
@asyncio.coroutine
3534
@hook.sieve(priority=100)
35+
@asyncio.coroutine
3636
def sieve_suite(bot, event, _hook):
3737
global buckets
3838

0 commit comments

Comments
 (0)