Skip to content

Commit

Permalink
py
Browse files Browse the repository at this point in the history
  • Loading branch information
ahuigo committed Jun 23, 2020
1 parent d2164d8 commit 1b94d8f
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 7 deletions.
10 changes: 5 additions & 5 deletions post/py/py-thread.md
Expand Up @@ -114,16 +114,16 @@ mutex:

在c语言里面就是用的futex

## close thread: via thread.Event
via a threadsafe threading.Event():
1. 利用e.wait() until e.set():
## 关闭 thread的方法: thread.Event
可以通过threading.Event() 以线程安全的方式关闭线程:
1.利用e.wait() until e.set():

e = threading.Event()
while not e.wait(0.5): # wait 会阻塞0.5秒
time.sleep(1)
print('end')

2. 利用e.is_set() until e.clear():
2.利用e.is_set() until e.clear():

e = threading.Event()
e.set()
Expand All @@ -139,7 +139,7 @@ via a threadsafe threading.Event():
e.clear()
thread.join()

3. close via thread attr:
3.close via thread attr:

def loop():
t = threading.currentThread()
Expand Down
7 changes: 6 additions & 1 deletion post/rb/rails-.md
Expand Up @@ -65,10 +65,15 @@ get/set session:
## response
response.headers["WWW-Authenticate"] = "Basic realm=\"#{realm}\""
render :plain => errormessage, :status => :unauthorized #401
render :plain => errormessage, :status => 401 #401

json

render :json => data
render :json => data, :status=>202

tmpl:

render(:file => File.join(Rails.root, 'public/403.html'), :status => 403, :layout => false)

### redirect
redirect
Expand Down
1 change: 0 additions & 1 deletion post/rb/rails-model.md
Expand Up @@ -36,7 +36,6 @@ private: true
puts "o: #{o.inspect}"
end


### where
.where('name LIKE :name OR email LIKE :name OR postcode LIKE :name', :name => t)

Expand Down

0 comments on commit 1b94d8f

Please sign in to comment.