小编Alo*_*lon的帖子

Redis ERR 未知命令“BZPOPMIN”

我按照这些说明(即sudo apt-get install redis-server)在 Windows 10 上的 Ubuntu Linux 子系统中安装了 Redis 版本 4.0.9 。

我在 Django 频道上关注本教程,并运行了以下代码:

>>> import channels.layers
>>> channel_layer = channels.layers.get_channel_layer()
>>> from asgiref.sync import async_to_sync
>>> async_to_sync(channel_layer.send)('test_channel', {'type': 'hello'})
>>> async_to_sync(channel_layer.receive)('test_channel')
Run Code Online (Sandbox Code Playgroud)

执行上面的最后一行时,出现此错误:

Traceback (most recent call last):
  File "<input>", line 1, in <module>
  File "C:\Users\xyz\Anaconda3\envs\django\lib\site-packages\asgiref\sync.py", line 120, in __call__
    return call_result.result()
  File "C:\Users\xyz\Anaconda3\envs\django\lib\concurrent\futures\_base.py", line 425, in result
    return self.__get_result()
  File "C:\Users\xyz\Anaconda3\envs\django\lib\concurrent\futures\_base.py", line 384, in __get_result
    raise self._exception
  File "C:\Users\xyz\Anaconda3\envs\django\lib\site-packages\asgiref\sync.py", line …
Run Code Online (Sandbox Code Playgroud)

redis django-channels

14
推荐指数
5
解决办法
9353
查看次数

VSCode更改垂直引导线缩进

我更改了 VSCode 设置,将制表符定义为 4 个空格,而不是默认的 2 个空格。如何使垂直引导线出现在每 4 个空格上,而不是每 2 个空格上?请参阅下面的屏幕截图。

在此输入图像描述

visual-studio-code

8
推荐指数
1
解决办法
3264
查看次数

Python Socket 接收/发送多线程

我正在编写一个 Python 程序,在主线程中,我使用 recv 函数通过 TCP 套接字连续(在循环中)接收数据。在回调函数中,我使用 sendall 函数通过同一个套接字发送数据。什么触发回调无关紧要。我已将套接字设置为阻塞。

我的问题是,这样做安全吗?我的理解是在单独的线程(不是主线程)上调用回调函数。Python 套接字对象线程安全吗?从我的研究中,我得到了相互矛盾的答案。

python sockets multithreading thread-safety

5
推荐指数
1
解决办法
7061
查看次数

重击与减法比较

我如何在bash中执行此操作:

while (var1 < (var2 - 1)) {
    ...
}
Run Code Online (Sandbox Code Playgroud)

现在,这就是我的bash:

while [ $var1 < $var2-1 ]
do
    ...
done
Run Code Online (Sandbox Code Playgroud)

bash

2
推荐指数
1
解决办法
32
查看次数

如何使用 gitpython 获取提交作者姓名和电子邮件?

当我运行时git log,每次提交都会得到这一行:“作者:姓名 <电子邮件>”。如何在 Python 中为本地存储库获取完全相同的提交格式?当我运行下面的代码时,我只得到作者姓名。

from git import Repo

repo_path = 'mockito'
repo = Repo(repo_path)

commits_list = list(repo.iter_commits())

for i in range(5):
    commit = commits_list[i]

    print(commit.hexsha)
    print(commit.author)
    print(commit.committer)
Run Code Online (Sandbox Code Playgroud)

python git gitpython

2
推荐指数
2
解决办法
2212
查看次数

Ubuntu docker-compose 错误的 Compose 文件版本

我在 Ubuntu 20.04 虚拟机中使用 docker-compose。我的 docker-compose 版本是docker-compose version 1.25.0, build unknown. 当我尝试构建时,出现以下错误:

ERROR: Version in "./docker-compose.yml" is unsupported. You might be seeing this error because you're using the wrong Compose file version. Either specify a supported version (e.g "2.2" or "3.3") and place your service definitions under the `services` key, or omit the `version` key and place your service definitions at the root of the file to use version 1.
For more on the Compose file format versions, …
Run Code Online (Sandbox Code Playgroud)

ubuntu docker docker-compose

2
推荐指数
1
解决办法
7660
查看次数