Skip to content

Commit

Permalink
feat: 更新工作日志& 添加python构建
Browse files Browse the repository at this point in the history
  • Loading branch information
TigerZH committed Apr 9, 2022
1 parent 711a3d0 commit 2e77f32
Show file tree
Hide file tree
Showing 3 changed files with 150 additions and 66 deletions.
13 changes: 13 additions & 0 deletions src/log/西筹官网.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# 西筹官网

##### 2022-04-02

- 修复“删除极致”文字错误
- 修复首页开发改成开放
- head添加首页标签
- 修改与底部间隔96px
- 企业文化 蒙版透明度改为增加
- 企业文化保存上滑特效
-

#####
85 changes: 25 additions & 60 deletions src/log/跨境电商.md
Original file line number Diff line number Diff line change
@@ -1,71 +1,36 @@
# Python
# 跨境电商

## Django rest framework
## 2022-04-07

```shell
# 当有增量的model修改或者删除的时候 先删除编译缓存文件
find . -path "*/migrations/*.py" -not -name "__init__.py" -delete
find . -path "*/migrations/*.pyc" -delete
#重新生成 makemigrations
python manage.py makemigrations
python manage.py migrate
# 后台部署 后台文件夹 /data/c18e/backend
ps aux|grep uwsgi
kill -9 PORT
uwsgi -d --ini application/uwsgi.ini
# 前端部署
yarn deploy
```
- 商户首页修改为文档页面
- 修复bug

## 2022-04-06

- 部署线上
- 修复抢红包弹窗不显示问题
- 修复网址长度字段限制导致无法上传的问题

## Python多进程和多线程哪个快?
## 2022-04-05

## 进程(process)
- 修改前端表单校验方案为react-hook-form
- 添加商户礼物设置模块
- 添加客户端礼物模块逻辑

```python
from multiprocessing import Process,Pool
import time
## 2022-04-04

def p_task(i):
time.sleep(2)

if __name__=='__main__':
# 单个
p = Process(target=p_task, args=())

p.start()
p.join()

# 多个
pools = Pool(4)
pools.apply_async(p_task, args=())
pools.apply_async(p_task, args=())
pools.close()
pools.join()
```
- 添加奖金模块
- 添加过期时间和用户网站字段
- 导入订单添加奖金金额字段
- 前端样式修改同步

## 线程(process)
## 2022-04-03

```python
import threading
import time
- 礼品卡话术模块
- 文件上传模块
- uwsgi部署改为高传输unix方式
- 增加域名模块
- 域名查询模块调试
- 前端使用tailwind支持
- 路由模块完善

def t_task(i):
time.sleep(2)


if __name__=='__main__':
t1 = threading.Thread(target=t_task, args=(1,))
t2 = threading.Thread(target=t_task, args=(2,))
t1.start()
t2.start()

```



- 对CPU密集型代码(比如循环计算) - 多进程效率更高
- 对IO密集型代码(比如文件操作,网络爬虫) - 多线程效率更高

对于IO密集型操作,大部分消耗时间其实是等待时间,在等待时间中CPU是不需要工作的,那你在此期间提供双CPU资源也是利用不上的,相反对于CPU密集型代码,2个CPU干活肯定比一个CPU快很多。那么为什么多线程会对IO密集型代码有用呢?这时因为python碰到等待会释放GIL供新的线程使用,实现了线程间的切换。
118 changes: 112 additions & 6 deletions src/note/python.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,119 @@
# Python

构建一项软件设计有两种方式:一种是将软件设计得足够简单以至于明显找不到缺陷;另一种是软件设计得足够复杂以至于找不到明显的缺陷。

​ ——查尔斯·安东尼·理查德·霍尔爵士(C. A. R. Hoare)

##### python
## QuickStart

```shell
mkdir drf-getting-start && cd drf-getting-start && virtualenv env && source env/bin/activate && pip install django && pip install djangorestframework && django-admin.py startproject apps . && python manage.py migrate && python manage.py createsuperuser
```


构建一项软件设计有两种方式:一种是将软件设计得足够简单以至于明显找不到缺陷;另一种是软件设计得足够复杂以至于找不到明显的缺陷。

​ ——查尔斯·安东尼·理查德·霍尔爵士(C. A. R. Hoare)
## Setup

```python
# 安装虚拟环境
pip install virtualenv
pip install virtualenvwrapper
# 进入django项目文件夹执行
virtualenv .env
# vscode选择刚刚设置的虚拟环境路径
command+shift+p > python:select interpreter

#进入虚拟环境
cd .env/bin
#激活虚拟环境
source activate
#退出虚拟环境Ï
deactivate
```



## Django rest framework

```shell
# 当有增量的model修改或者删除的时候 先删除编译缓存文件
find . -path "*/migrations/*.py" -not -name "__init__.py" -delete
find . -path "*/migrations/*.pyc" -delete
#重新生成 makemigrations
python manage.py makemigrations
python manage.py migrate
# 当已有数据添加字段时
python manage.py migrate --fake

# 创建超级管理员
python manage.py createsuperuser
# 后台部署 后台文件夹 /data/c18e/backend
ps aux|grep uwsgi
# 停止后台uwsgi服务
sudo pkill -f uwsgi -9
# 启动服务
# 需要进入项目文件夹执行命令
uwsgi -d --ini application/uwsgi.ini
# 停止服务
uwsgi --stop PIDFILE
# 重启uwsgi
sudo service uwsgi restart
# 前端部署
yarn deploy
```



## Python多进程和多线程哪个快?

## 进程(process)

```python
from multiprocessing import Process,Pool
import time

def p_task(i):
time.sleep(2)

if __name__=='__main__':
# 单个
p = Process(target=p_task, args=())

p.start()
p.join()

# 多个
pools = Pool(4)
pools.apply_async(p_task, args=())
pools.apply_async(p_task, args=())
pools.close()
pools.join()
```

## 线程(process)

```python
import threading
import time

def t_task(i):
time.sleep(2)


if __name__=='__main__':
t1 = threading.Thread(target=t_task, args=(1,))
t2 = threading.Thread(target=t_task, args=(2,))
t1.start()
t2.start()

```



- 对CPU密集型代码(比如循环计算) - 多进程效率更高
- 对IO密集型代码(比如文件操作,网络爬虫) - 多线程效率更高

对于IO密集型操作,大部分消耗时间其实是等待时间,在等待时间中CPU是不需要工作的,那你在此期间提供双CPU资源也是利用不上的,相反对于CPU密集型代码,2个CPU干活肯定比一个CPU快很多。那么为什么多线程会对IO密集型代码有用呢?这时因为python碰到等待会释放GIL供新的线程使用,实现了线程间的切换。



Expand Down Expand Up @@ -350,7 +456,7 @@ print ("相加后的值为 : ", sum( 20, 20 ))


- 模块
模块的概念是非常核心的,如果想对python了如指掌,运筹帷幄。信手捏来。模块的思维和掌握必不可少。
模块的概念是非常核心的,如果想对python了如指掌,运筹帷幄。信手捏来。模块的思维和掌握必不可少。

```python
# 系统自带的模块导入
Expand Down Expand Up @@ -383,7 +489,7 @@ print ("相加后的值为 : ", sum( 20, 20 ))

mymodule.say_hi()
print('Version', mymodule.__version__)
__init__ __main__
__init__ __main__
# 函数是程序中的可重用部分那般,模块是一种可重用的程序。包是用以组织模块的另一种层次结构
```

Expand Down Expand Up @@ -623,7 +729,7 @@ __init__ __main__

-

-




Expand Down

0 comments on commit 2e77f32

Please sign in to comment.