| Home | 最新文章 | 登入 | 申請網誌

i18n


These days, I do the internationalization (i18n) for our application. It really a painful process.

There are three parts of the system need to do the i18n:

1) normal HTML (but is template html)
2) python code
3) javascript

For 1), 2), there are a tools to do - itools. Thanks for the creators of these tools, it makes the translation not that painful. And the tutorial is a good start too (i18n made easy).

For 3), the javascript part, I cannot find any good methods to do the i18n. And I found a blog that talks about how to do the i18n in javascript (24 ways: Javascript i18n). This is the start point of my work of i18n the javascript. It talks about how to use the javascript object to be the dictionary for the translation.

Following this direction, I wrote a python script to extract the strings with the pattern `_(”xxxx”)' or `_('xxxx')' and another script to build the javascript dictionary as the 24 ways talks about. But of course, I need to add the hook _(….) to all the strings needed to translate.

All together, I spent a week to build the i18n architecture and extract all the strings to translate. Then, I pass the translation file to my colleague to do the “real” translation.

FYI, there are almost a thousand strings to translate.

 




按此回應 回應的RSS 暫時未有引用通告  (0)


Try on Django Framework


These two days, I have been trying on the django web framework. What is django framework?

Quote from official homepage:
“”"
Django is a high-level Python Web framework that encourages rapid development and clean, pragmatic design.
Developed and used over two years by a fast-moving online-news operation, Django was designed to handle two challenges: the intensive deadlines of a newsroom and the stringent requirements of the experienced Web developers who wrote it. It lets you build high-performing, elegant Web applications quickly.
“”"



(閱讀全文)


按此回應 回應的RSS 暫時未有引用通告  (1)


Threading Hell


I tried to evaluate our python based web server today. Some strange behaviour happened. The web server can work with 5 concurrent connections perfectly, but it work slowly with 6 concurrent connections. We thought of many reasons why this strange thing happened. The speed of 6 concurrent connections is 15-30 times slower than the 5 concurrent connections. But if I added some codes to print some messages on screen in the web server, the critical point is 6 to 7. We found that the performance degraded much if the server tries to create more than 6 threads.

There are many reasons we have thinked of. Maybe the speed of the handling process (our written code) of the request is slow. Maybe the maximum number of threads in python is six (really? i dont believe it). Maybe the OS  (win2k) limitations (wah..just 6 threads?!).

After several hours of testing, I found that our written code is really fast (about 1ms), so it is not the reason. And i dont believe that the max. no. of threads of python and win2k is just six. So I just conclude that python or OS or something else do not collect the finished threads immediately after processed the request. However, I cannot think of any reason why and how it would be liked that.

Lastly, Leo (my colleague) think that the web server process do not have enough CPU cycles for each time of processing, so it cannot share the CPU times for more than six threads. Then the solution is to increase the priority of the process. Ah..ha, it turns out that the web server run smoothly even if having 64 concurrent connections when changing the process priority to high.

Below is the details of the process how the process cannot process with more than 6 connections smoothly:
1) the web server has 7 threads (they have been finished processing, and in closing state)
2) OS schedule an amount of CPU cycles to the web server process
3) web server process shares CPU cycles to 7 threads
4) each thread used some CPU cycles to do the context switching
5) just left small amount of CPU cycles for each thread to close, however the closing process of the thread in python is not that cheap (just I think)
6) the threads just do little things and the web server process used up the CPU cycles
7) the web server process need to pass the control to OS
8) Repeat to 1) again

So after increasing the priority, OS gives more CPU cycles to the web server process, so the threads have enough CPU cycles to close… that’s the story of threading hell.

 


按此回應 回應的RSS 暫時未有引用通告  (0)


Python Challenge


Recently, I am playing a game called “Python Challenge” which is
used to let the player learn how to program in Python. Python is high
in productivity and cross-platform. You can develop a software within a
day by using this language. The challenge is really very challenging.
You have to grab all the hints from a webpage and do some related tasks
in order to proceed to next level. Now, my status is in level 14. If
you want to have a try, click the image below.

 Python Challenge

 


按此回應 回應的RSS 暫時未有引用通告  (0)


| 1