Python Coroutine

Date Tags Python

yield: 产出和让步

在协程中yield通常出现在等号的右边 data = yield,可以产出值,也可以不产出。

data = yield # yield关键字后没有表达式,表示没有产出值,即None

协程从调用方通过.send(data)接收数据。

yield还是一种流程控制工具,把cpu让步给调度器,从而激活其他协程。

生成器如何进化成协程

生成器的调用方可以使用.send(...)方法发送数据,发送的数据会成为生成器函数中yield表达式的值。因此,生成器可以作为协程使用。协程是指一个过程,这个过程预调用方协作,产出由调用方提供的值。


Apache2 MacOS

Apache2 version: sudo apachectl -v

Apache2 diename: /etc/apache2

Apache2 config path: /etc/apache2/httpd.conf

Defualt Web source dirname DoucumentRoot: /Library/WebServer/Documents

  • httpd.conf
DocumentRoot "/Library/WebServer/Documents"

Listen 80

sudo apachectl start/restart/stop

Enable virtual host

sudo vi /etc/apache2/httpd.conf

# Include /private/etc/apache2/extra/httpd-vhosts.conf, remove '#'

Config virtual host

sudo vi /etc/apache2/extra/httpd-vhosts.conf

<VirtualHost *:80>
    ServerAdmin webmaster@jerrylsu.local
    DocumentRoot "/Users/jerry/Documents/blog/output"
    ServerName jerrylsu.local
    ServerAlias www.jerrylsu.local
    ErrorLog "/private/var/log/apache2/jerrylsu.local-error_log"
    CustomLog "/private/var/log/apache2/jerrylsu.local-access_log" common
</VirtualHost>

<VirtualHost *:80>
    ServerAdmin webmaster@isso.jerrylsu.local
    DocumentRoot "/Users/jerry/Documents/blog/isso"
    ServerName isso.jerrylsu.local
    ErrorLog "/private/var/log/apache2/isso.jerrylsu.local-error_log"
    CustomLog "/private/var/log/apache2/isso.jerrylsu.local-access_log" common
</VirtualHost>
                    more ...
                


Apache2 Deploy Multi-sites

I submit the issue

1. Isso as systemd service

Switch back to your privileged(root) user and create new service file.

vim /etc/systemd/system/isso.service Paste the following in it.

[Unit]
Description=Isso Commenting Server
After=network.target
[Service]
Type=simple
User=isso
WorkingDirectory=/home/isso
ExecStart=/home/isso/.local/bin/isso -c /home/isso/isso.conf
Restart=on-failure
RestartSec=5
[Install]
WantedBy=multi-user.target

Enable and start the service.

systemctl enable isso

systemctl start isso

Check the status.

systemctl status isso

  • apache2 Multi-sites

  • 阿里云二级域名

  • Apach2 as reverse proxy

1.1 新增站点配置文件





Pointer Networkers



Utterance Rewriter